[AccessD] FindFirst Not Working

A.D.Tejpal adtp at airtelmail.in
Mon Jul 13 00:49:40 CDT 2009


Rocky,

    Simplified one line statement directly using form's recordset is quite safe. In case of no match the form goes to the first record. There is no error so long as the criteria string is OK and free from any data type mismatch. If it is desired to notify the user in case of no match, the following code could be adopted:

'==============================
    With Me.Recordset
        .FindFirst  "<<MyCriteriaString>>"
        If .NoMatch Then
            MsgBox "No Matching Record"
        End If
    End With
'==============================

    However, if the situation also demands that in case of no match the form should stay at the existing record, following code, based upon form's RecordsetClone could be preferred:

'==============================
    With Me.RecordsetClone
        .FindFirst  "<<MyCriteriaString>>"
        If .NoMatch Then
            MsgBox "No Matching Record"
        Else
            Me.Bookmark = .Bookmark
        End If
    End With
'==============================

Best wishes,
A.D. Tejpal
------------

  ----- Original Message ----- 
  From: Rocky Smolin 
  To: 'Access Developers discussion and problem solving' 
  Sent: Monday, July 13, 2009 02:07
  Subject: Re: [AccessD] FindFirst Not Working


  A.D:

  Thanks for the simplification.  The one-liner works of course.  I suppose it
  can be used where there's no possibility of a NoMatch as when you're pulling
  the PK from a combo box where the row source is from the target table?

  Rocky


More information about the AccessD mailing list