I am trying to use an unbound textbox and button to search my ID column (Barcode) and list the record in a form.
The issue I'm having is that according to many examples it looks correct, but I'm new to VBA.
Private Sub searchbutton_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
DoCmd.OpenForm "Update"
Set rst = Forms!Update.Recordset.Clone
rst.FindFirst (Barcode) = & Me.searchtext
Forms!Update.Bookmark = rst.Bookmark
DoCmd.Close acForm, Me.Name
End Sub
The issue is with line rst.FindFirst (Barcode) = & Me.searchtext and throws a syntax error, but no specifics.
I've also tried:
rst.FindFirst [Barcode] = Me.searchtext
rst.FindFirst "[Barcode] = " Me.searchtext
rst.FindFirst (Barcode) = " Me.searchtext
The [Barcode] lines throw:
Run-time error '3464' Data type mismatch in criteria expression.
the Barcode field is ShortText as it needs to support my barcodes which as "000001".....
&character. Should be this:rst.FindFirst "[Barcode] = '" & Me.searchtext & "'"