Synchronize a DAO Recordset's record with a form's current record
The following code example uses the RecordsetClone property and the Recordset object to synchronize a recordset's record with the form's current record.
When a company name is selected from a combo box, the FindFirst method is used to locate the record for that company, and the Recordset object's Bookmark property is assigned to the form's Bookmark property, causing the form to display the found record.
Sub SupplierID_AfterUpdate()
Dim rst As Recordset
Dim strSearchName As String
Set rst = Me.RecordsetClone
strSearchName = Str(Me!SupplierID)
rst.FindFirst "SupplierID = " & strSearchName
If rst.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for