Return Records Equal not Like in VBA [Solved/Closed]

Report
-
 Andy -
Hello,
I have created a database for tracking cell phones and everything was working great until my records got over 110. Now when I bring up record 112 and run the following script I get the information for both record 112 and 12! I think it's the "Like" condition in the last line of code but I have tried to replace it with "=" and that doesn't work. What can I do to fix this? This code is runing as the function of a button when the button is pressed it prints all the information for the selected custodian to the HReceipt form.

Private Sub HReceipt_Click()

'User must select a value from the combo box
If IsNull(CustodianID) = True Then
MsgBox "You must select a keyword."

'Open report called HReceipt where the PartsReplaced field
' contains the value in the hrcustodian combo box
Else
DoCmd.OpenReport "HReceipt", acViewPreview, , "ID Like '*" & ID & "*'"
End If

End Sub


Thank you!

1 reply

Thanks, I found the answer myself it was just a matter of putting in the right syntax. The line needed to be this:

DoCmd.OpenReport "HReceipt", acViewPreview, , "ID=" & ID

Now it works!