I have created a form to search for a model number in a table. Say the model number is ABC-123. The current code I have written makes an exact match so ABC-123 would have to be entered for the return of the data record. I want it to be able to pull a partial match, so if you enter ABC it would pull back the ABC-123 and if there is a ABC-555 it comes back also. I have pasted my current code that gives exact matches below. Thanks for your help.
Private Sub Text0_AfterUpdate()
Dim RecNum As Variant
Dim FrmLnkCriteria
RecNum = DLookup("[Model]", "Inventory", "[Model] = '" & Forms!Model_Lookup!Text0 & "'")
If IsNull(RecNum) Then
MsgBox "The model you entered is invalid. Please check the model and try again.", vbOKOnly, "Invalid Model"
Me!Text0 = ""
Me!Text0.SetFocus
Else
FrmLnkCriteria = "[Model]=" & "'" & Me![Text0] & "'"
DoCmd.OpenForm "Inventory_Lookup", , , FrmLnkCriteria
End If
End Sub
Private Sub Text0_AfterUpdate()
Dim RecNum As Variant
Dim FrmLnkCriteria
RecNum = DLookup("[Model]", "Inventory", "[Model] = '" & Forms!Model_Lookup!Text0 & "'")
If IsNull(RecNum) Then
MsgBox "The model you entered is invalid. Please check the model and try again.", vbOKOnly, "Invalid Model"
Me!Text0 = ""
Me!Text0.SetFocus
Else
FrmLnkCriteria = "[Model]=" & "'" & Me![Text0] & "'"
DoCmd.OpenForm "Inventory_Lookup", , , FrmLnkCriteria
End If
End Sub