Dlookup Syntax Help

X

Xaa

I have a Form called Leads that is derriven from a query whose main
table is also called Leads. On the form the user enters a zipcode and
I would like to use Dlookup to automatically fill in the State field.
The table it would lookup in is called Zip.

So I want to know the syntax in the form for the field to look into the
table called Zip and produce the field called State where the field Zip
in table Zip equals the field Zip from the form Leads.

I hope that makes sense.

Bill
 
F

fredg

I have a Form called Leads that is derriven from a query whose main
table is also called Leads. On the form the user enters a zipcode and
I would like to use Dlookup to automatically fill in the State field.
The table it would lookup in is called Zip.

So I want to know the syntax in the form for the field to look into the
table called Zip and produce the field called State where the field Zip
in table Zip equals the field Zip from the form Leads.

I hope that makes sense.

Bill

So you have a field named Zip in a table named Zip?

Perhaps you would not be so confused if you had named the Leads table
'tblLeads', the Zip table 'tblZip, the Zip field 'txtZip', and the
form 'frmLeads'.

Assuming the Zip field is text datatype (as it should be):

=DLookUp("[State]","Zip","[Zip] = '" & Me![Zip] & "'")

Make sure the name of the control is not State or Zip!

Change the table and field names so that in 6 months or so, whoever
reads your code (including you) will be able to make sense out of it.
 
X

Xaa

Fred,

Thanks, that worked fine. I appreciate your help as well as the naming
tips. I think I better re-do most of the naming now so it doesn't get
any more complicated.

Bill
 

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