DLOOKUP

K

kms

I WANT AN UNBOUND CONTROL BOX IN MY FORM CALLED [VENDOR NAME] TO DISPLAY THE
VENDOR NAME RELATED TO THE [VENDOR NUMBER] FIELD IN THE FORM IM WORKING IN.
THE [VENDOR#] FIELD IS TAKEN FROM MY PO TABLE. I ALSO HAVE A TABLE CALLED
VENDOR LIST THIS IS THE DLOOK-UP EXPRESSION I'M TRYING TO USE BUT IT KEEPS
GIVING ME AN ERROR MESSAGE
=DLookUp("[VENDOR NAME]","[Vendor list ]","[VENDOR NAME] =" & Forms![PO
FORM]![VENDOR #])

PLEASE HELP!!
 
R

Ray

First, remove the space following the word List in [Vendor List ]

Second, your criteria doesn't look right.

"[VENDOR NAME] =" & Forms![PO FORM]![VENDOR #])

I suspect it should be something like this:

"[VENDOR #] =" & Forms![PO FORM]![VENDOR #])

Otherwise you are searching the vendor name field for your vendor number.

And finally, if your vendor number is a text field, you need to surround the
value with quotes like this:

"[VENDOR #] ="""" & Forms![PO FORM]![VENDOR #] & """")

And finally, you should probably deal with the possibility that it returns a
null value as follows:

=Nz(DLookUp("[VENDOR NAME]","[Vendor list ]","[VENDOR #] =" & Forms![PO
FORM]![VENDOR #]), "")


Ray
 
L

Larry Linson

Have you considered using a Query as Record Source for the Form, and, in
that Query join the PO Table and the Vendor List on the Ven dor #? That
seems so much simpler than using DLookup as Control Source.

Larry Linson
Microsoft Office Access MVP
 

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