MS Access vb code to search for string (using the LIKE) statement

Viewed 1118

I have a from in Microsoft Access with a text box (name below is TextSerial). I want users to be able to enter in a string and have it display all matching records in a sub-form. Below is my code, but it is not working (no records come up).

Private Sub TextSerial_Enter()
Dim myEquipment As String
myEquipment = "Select * from tblEquipment where ([Serial] Like '% " & Me.TextSerial & " %' )"
Me.tblEquipment_subform1.Form.RecordSource = myEquipment
Me.tblEquipment_subform1.Form.Requery
End Sub

I have a feeling that it has something to do with the order of the quotations (' vs ") but I haven't been able to figure it out. I want the users to be able to only enter part of the string (which is why I am using Like instead of =). Thanks!

3 Answers
Related