DLookup problem

S

Silvio

I have two tables tblAddress and tblCity both tables have store a CityID

I have a form based on tblAddress, this form has an unbounded control that
need to lookup the cityID in tblCity and display the corresponding name this
is what I have done:

=DLookUp("City","tblCity","CityID= CityID")

The problem is that all my records display the same city name despite the
cityID being different. What I am doing wrong?

Thanks folks.
 
S

Silvio

That works. Thank you.

Chris O'C via AccessMonster.com said:
Use the name of the CityID's control. If the value is a number:

=DLookUp("City","tblCity","CityID=" & txtCityID)

If the value is a string, surround it by single quotes:

=DLookUp("City","tblCity","CityID='" & txtCityID & "'")

Chris
Microsoft 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