misuser2k7
MIS
I have created a form named 'CustIDpromptform' which has a textbox to enter customerid (long integer) and a command button which is supposed to open a second form which displays customer contact information when a customerid is entered in the textbox and the command button is clicked.
The display form (second form) is based on a simple query called 'custInformationQuery':
Select * from custInformationTable where customerid = Forms!CustIDPromptForm!customerid;
The table 'custInformationTable' has fields customerid (PK), customerName, customerAddress, customerPhone, customerEmailAddress. These fields are control sources for the textboxes in the second form.
The command button is coded to open second form called CustContactInformationForm.
Dim customerid As Long
If customerid = dlookup(customerid, “custInformationTable”) then
Docmd.openform “CustContactInformationForm”
Else: MsgBox("Check Customer ID and try again")
End if
But even when a valid customerid (with a complete corresponding customer record) is entered and the command button is clicked, only the "Check Customer ID and try again" message is displayed.
However, if the query (custInformationQuery) is run directly it prompts for textbox value of the customerid and shows/returns complete customer record associated with the customerid.
Is there a way to ensure the second form opens up displaying the information like the query it is based on does?
Thank you for your help.