Use combo box to find record

Private Sub ComboBoxSurname_AfterUpdate()
‘ Find the record that matches the control in a ComboBox
Dim A
Dim dbase As DAO.Database
Dim recset As Object
Set dbase = CurrentDb
Set recset = Me.Recordset.Clone
‘ Set the variable “A” to equal the value selected in the ComboBox
A = Me.ComboBoxSurname.Value                                                                ‘ Name of the Combobox
‘Using the Field titled “NUMBER” find the first record that matches
recset.FindFirst “[Number] = “”” & A & “”””                                               ‘ Notice the 3 sets of quotation marks
‘ If Found then move to the appropriate record
If Not recset.EOF Then Me.Bookmark = recset.Bookmark
End Sub

Comments are closed