DLookup problem

  • Thread starter Thread starter Silvio
  • Start date Start date
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.
 
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
 
Back
Top