Simple Dlookup probem (1 Viewer)

h33

Registered User.
Local time
Today, 03:08
Joined
Aug 7, 2006
Messages
10
I have a form called 'Order Details' that contain a field called 'Name' and combobox called 'Product Code'. The combo box is sourced from a table called 'Titles'.

When the value in the combobox 'Product Code' is changed, I would like the 'Name' field to lookup the corresponding value from the 'Titles' table. But I can't get Dlookup to work. And it's driving me mad! Here's the code I'm using as the Control Source for the 'Name' text box:

=DLookUp("[Title Name]","Titles","
Code:
=forms!Order_Details![Product Code]")
 

allan57

Allan
Local time
Today, 03:08
Joined
Nov 29, 2004
Messages
336
try this

=DLookUp("[Title Name]","Titles","
Code:
=" & forms!Order_Details![Product Code])
 

dajabo

Registered User.
Local time
Today, 03:08
Joined
Dec 16, 2004
Messages
17
h33 said:
=DLookUp("[Title Name]","Titles","
Code:
=forms!Order_Details![Product Code]")[/QUOTE]

You need to take the reference to the form control out of the double quotes, so something like:

=DLookUp("[Title Name]","Titles","[Code]='" & forms!Order_Details![Product Code] & "')

Notice I put single quotes after the second = and before the last bracket. If the variable is an integer you should drop these.

Hope this helps. DLookup has caused me many a headache!
 

Users who are viewing this thread

Top Bottom