Trouble Again...DLookup function

B

Becker

I have two related tables (Inventor) and (Vendor) with a form based on the
Inventor table.

When I am adding a new record into the Inventor table through a form, I want
the Vendor Name field to fill in the Vendors name after I key in the
Vendor's code number.

I am trying to use the DLookup function...... such as......

Sub Vencode_OnExit(Cancel as Integer)
Dim varVenname as Variant

varVenname = DLookup("Venname", "Vendor","Vencode=[Vencode]')

If (Not IsNull(varVenname)) Then Me![Venname] = varVenname

End Sub

It should work. Where am I going wrong?

Thanks,

Becker
(e-mail address removed)
 
K

Ken Snell

Try this:

varVenname = DLookup("Venname", "Vendor","Vencode=" & Me.Vencode)

You need to concatenate the value of the Vencode control into the
"criterion" string.
 

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

Similar Threads

DLOOKUP 2
DLOOKUP HELP 1
Text wildcards 1
dlookup challanges 1
Using Min Function within DLookup Function 0
Record validation before save 1
Dlookup and Conditional Formatting 3
DLookup Function 2

Top