I am trying to set up a form where you enter a zip code and the city and state automatically populate. I can't get the Dlookup statement to work. I am hoping I can get some help.
I have a table called tblZipCodeData it has fields Zipcode, City, and State all three fields have a datatype of ShortText.
The form has three textboxes called txtZipCode, txtCity and txtState.
The txtCity textbox has the code in the afterupdate event box:
The txtState textbox has:
I don't get any errors but the textboxes don't populate. I am entering a zip code that I know exists in the table. At first, I was entering a zip code that had a zero in front of it and the zero keeps on disappearing so I started entering a zipcode that starts with 1 to avoid that issue.
I have a table called tblZipCodeData it has fields Zipcode, City, and State all three fields have a datatype of ShortText.
The form has three textboxes called txtZipCode, txtCity and txtState.
The txtCity textbox has the code in the afterupdate event box:
Code:
=DLookUp("City","tblZipCodeData","ZipCode='" & txtZipCode & "'")
The txtState textbox has:
Code:
=DLookUp("State","tblZipCodeData","ZipCode='" & txtZipCode & "'")
I don't get any errors but the textboxes don't populate. I am entering a zip code that I know exists in the table. At first, I was entering a zip code that had a zero in front of it and the zero keeps on disappearing so I started entering a zipcode that starts with 1 to avoid that issue.