DLookUp and confused...

  • Thread starter Thread starter JB5498
  • Start date Start date
J

JB5498

Guest
I am trying to do a simple Dlookup to ease data entry. Here's what I've got...

Tables:
Clients
-Client
-Company
-Address
-Address2
-Phone
-Ext
-Fax

Orders
-OrderID
-ClientID

Clients Query
-Client
-Company
-Address
-Address2
-Phone
-Ext
-Fax

Form
-OrderID
......... and then I want to add a drop-down to select the clients name and have all of their address and phone information populate in separate text boxes automatically. I created a combo box with the Client Query as the record source. Now I am trying to add a text box for the clients company using =DLookUp("Company","[Client Lookup Query]","Client=" & Company) but instead of returning the company it returns the error #Name?. Can anyone see what the problem is? What am I doing wrong...

BTW,.. this would be my first attempt at Dlookup. Thanks
 
Perhaps your brackets are wrong.

Try:
=DLookUp("[Company]","Client Lookup Query","[Client]=" & Company)

You may also need to specify the form with something like:
=DLookUp("[Company]","Client Lookup Query","[Client]=" & Forms![FormName]![Company])
 
OK, I tried the suggestion...

I tried your suggestion and I'm still getting the error. Is there a really good reference out there for "dlookup for the extrememly confused"? I have been struggling with this for so long now.. my head is about to switch off.
 
It's hard for me to say without seeing it, but this is what I would try based on the tables and queries you listed.

=DLookUp("[Company]","Client Lookup Query","[Client]=" & Forms![OrderID]![txtClientID])

In order for this to work, you would need your form to be called OrderID, and you'll need to substitute in the name of your drop down box for [txtClientID]

You could also put this code in the "After Update" event of the drop down box by setting the name of your text box equal to that code.

ie - txtCompanyName=DLookUp("[Company]","Client Lookup Query","[Client]=" & Forms![OrderID]![txtClientID])
 

Users who are viewing this thread

Back
Top Bottom