How do I use dlookup in a form to find a specific field

J

Josh

I have a textbox with the following control source:

Code:
=DLookUp("[Heater Type]","Washers","[Model Number] =
LabelModelNumber.caption)"

So basically I am trying to look up the heater type from the washers table
by the model number. On the form I have it so the user select the type of
washer they want and it displays the model number on the form via a label.

It appears to just be grabbing the first item in the heater type field, so
"labelmodelnumber.caption" must be the problem, but I can figure out what I
need to change it too.
 
D

Daryl S

Josh -

You need to evaluate the LabelModelNumber.caption outside of the
double-quotes, and add in the single-quote delimeters if it is a text field.
Try this:

=DLookUp("[Heater Type]","Washers","[Model Number] = '" &
LabelModelNumber.caption & "'")

If Model Number is a number field, then use this:

=DLookUp("[Heater Type]","Washers","[Model Number] = " &
LabelModelNumber.caption )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top