Trouble Again...DLookup function

  • Thread starter Thread starter Becker
  • Start date Start date
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)
 
Try this:

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

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