Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup Help

Status
Not open for further replies.

nwalk81

Technical User
Sep 30, 2003
29
US
Hello All

I have a main form which has a subform. I need the subform information to populate into the subform according to a number on the main form. Currently I am trying dlookup to retrieve this information.

The main form has an Employee ID, I want the users to be able to copy and paste this ID and the information to populate accordingly.

I placed this code directly in the textbox but I receive a #Name? error.
Code:
 Me![Claim Code].ControlSource=DLookup("[Claim Code]","[Claim Info]","[ID]='"&ID)&"'"

I even tried to take out the Me! being that it's a form to no avail.

I need to do this for 11 textboxes on this subform with text and date properties.

Also, there may be an occurrence where there is more than one row of information for an ID. How would I code it to show each, using the subform navigation.

Can someone please help me?

Thanks!
 
Is the ID field numeric or text? If numeric, try taking off the single quotes at the end of your dlookup statement.

Code:
Me![Claim Code].ControlSource=DLookup("[Claim Code]","[Claim Info]","[ID]= "& ID)

Also, if you copied exactly from your code, it looks like you have a parenthesis misplaced. It should be like the following:

Code:
Me![Claim Code].ControlSource=DLookup("[Claim Code]", "[Claim Info]", "[ID]= '" & ID &"'")

Also, it wouldn't hurt to change the spacing to what I have here.
 
Thank you, but my issue was not with dlookup because I was trying to get to the actualy record and edit that record. I noticed dlookup mirrors the information in a new record. I had to fix my tables and the subform automatically populated. Thanks for the reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top