[AccessD] FindFirst Not Working

Rocky Smolin rockysmolin at bchacc.com
Mon Jul 13 07:42:43 CDT 2009


A.D.:

The second method is the one I've always used.  I probably cribbed it from
one of your posts years ago.

Best,

Rocky
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D.Tejpal
Sent: Sunday, July 12, 2009 10:50 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] FindFirst Not Working

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
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list