Dlookup

G

Guest

I want the input (cancon) into a textbox to determine what displays (VIN) in
another textbox.


Dim varX As Variant
varX = DLookup("[VIN]", "contract", "[Contract number] =' _ &
Forms![Form1]!cancon)



where do I put this in the input box (properties) i have tried several
different ways and nothing is coming up in the VIN text box.
 
S

Sandra Daigle

I see a few syntax errors in the Dlookup statement - first there should be a
double quote after the equals sign. Second the & should be on the next
line - I'm guessing that these errors are typos in your post and not in your
code else you'd have compile errors. Anyway - You need to assign the value
returned to the other textbox - lets say it is named txtVin. Then you assign
it this way (after the Dlookup statement).

me.txtVin=VarX

This should probably go into the AfterUpdate event of the cancon control.
Also, if cancon is an alphanumeric field you will need to wrap quotes around
the test value in the Dlookup statement:

varX = DLookup("[VIN]", "contract", "[Contract number] =""" _
& Forms![Form1]!cancon & """")
 

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