Thank you for your reply and ideas. I have been trying your suggestion with the DLookup function. The statement I wrote is as follows
Code:
Dim ProductID As Integer
ProductID = DLookup("[ProductID]", "Product", "ProductName=" & XRefCode)
The problem I think I have is that ProductID is an autonumber on the table Product and gives me this error. Data type mismatch in criteria expression. What is the vba data type for an autonumber? I have tried Long Integer but it does not work. Do you have any suggestions?