UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> BookmarkProperty    
BookmarkProperty

Related Content:
    Recordsets for Beginners


The Bookmark property of the DAO Model can be used to navigate to a specific record on a form without needing to know the position of the record.

By using the .FindFirst method of the DAO Recordset, we can pass Where Clause-like criteria to find and navigate to the record that matches.

From a Form, this can be done by using the Form's Recordset or RecordsetClone object. When used on the RecordsetClone of a Form, the Bookmark property of the form must be explicitly set. When using the Recordset of a Form, the Bookmark property will be automatically set when (if) the record is found. With a recordset object, the cursor is automatically moved to the bookmark position when the record is found.

CODE

'assume a field name of fldID and Numeric datatype
'assume control name of ctlID to hold the searchable value

With Me.Recordset

 .FindFirst "fldID = " & Me.ctlID

 'if the record exists, we need not explicitly set the bookmark
 'property as we are using a Form's Recordset

 If .NoMatch Then
   'no record found
   MsgBox "Record ID " & Me.ctlID & " not found!"
 End If
End With


CODE

'assume a field name of fldID and Numeric datatype
'assume control name of ctlID to hold the searchable value

With Me.RecordsetClone

 .FindFirst "fldID = " & Me.ctlID

 If .NoMatch Then

   'no record found
   MsgBox "Record ID " & Me.ctlID & " not found!"

 Else

   'if the record exists, we need to explicitly set the bookmark
   'property as we are using a Form's RecordsetClone

   Me.Bookmark = .Bookmark

 End If
End With

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 6,951 times.  This page was last modified 16:59, 11 February 2012 by Jack Leach.   Disclaimers