Results 1 to 6 of 6
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Find record based on record ID

    In looking among the various forms of DoCmd, I don't find a method like "DoCmd.FindRecord MyRecordID = intNumber". Where such a command would be used in the code sheet of a continuous form. Google spit out some stuff but didn't see anything quite like I'm asking. ("MyRecordID" is the ID field of the current form's RecordSource.)

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Are you saying you weren't able to find this
    https://msdn.microsoft.com/en-us/vba...or=-2147217396
    or that somehow, it's not relevant to your situation?

    Your example is a bit more like a DLookup than FindRecord.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Completely failed to assimilate the meaning of AcFindField as it applied to my situation, problem solved.
    Thanks,
    Bill

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Here's some boilerplate search code, to do this.

    If MyRecordID is defined as Text:

    Code:
    Private Sub btnSearch_Click()
     If Not IsNull(Me.SearchField) Then
       Me.Recordset.FindFirst "[MyRecordID]='" & Me.SearchField & "'"
         If Me.Recordset.NoMatch Then
           MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
         End If
     End If
    End Sub
    If MyRecordID is defined as a Number:

    Code:
    Private Sub btnSearch_Click()
     If Not IsNull(Me.SearchField) Then
       Me.Recordset.FindFirst "[MyRecordID]=" & Me.SearchField 
         If Me.Recordset.NoMatch Then
           MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
         End If
     End If
    End Sub

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Code:
    Me.Recordset.FindFirst "[MyRecordID]=" & Me.SearchField
    Far more applicable to my situation than "FindRecord". (My mind always seems to think of cloned recordsets when FindFirst.... Next, Last, etc comes into play)
    Thanks,
    Bill

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Web based forms and find record
    By haywam59 in forum Forms
    Replies: 3
    Last Post: 04-07-2016, 01:36 PM
  2. Find record based on text box
    By tazzzz in forum Forms
    Replies: 20
    Last Post: 12-21-2015, 01:59 PM
  3. Find Record with date before Current Record
    By mrmims in forum Queries
    Replies: 1
    Last Post: 10-01-2015, 08:10 AM
  4. Replies: 1
    Last Post: 06-23-2014, 07:21 AM
  5. Replies: 4
    Last Post: 04-01-2014, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums