greedbegone
Technical User
Hello,
I have an Access 2007 database that i am building with the following:
Tables:
1. tblCustomer
2. tblZip
I have created a 1 to many relationship between them with the tblZip being the parent table. I have created a form with both tables. I have added customer name from tblCustomer, Zip from tblCustomer and then created 2 unbound text boxes named: City and State. The Zip field is a combo box. I have it set up to where I enter the zip code and the corresponding city and state auto populate the two unbound boxes. I have placed the following event on the Zip combo box:
After Update:
Private Sub Zip_AfterUpdate()
City = DLookup("City", "tblZip", "Zip = '" & Me.Zip & "'")
State = DLookup("State", "tblZip", "Zip = '" & Me.Zip & "'")
End Sub
Everything works great until I actually enter or select the zip code for the combo box... the moment i hit the tab key, it auto populates the city and state with the wrong "city" and "state" information. Along with that, it doesn't seem to update when i go back and enter a different zip code... Hopefully this makes sense... I would appreciate any help with this.
Thank you.
I have an Access 2007 database that i am building with the following:
Tables:
1. tblCustomer
2. tblZip
I have created a 1 to many relationship between them with the tblZip being the parent table. I have created a form with both tables. I have added customer name from tblCustomer, Zip from tblCustomer and then created 2 unbound text boxes named: City and State. The Zip field is a combo box. I have it set up to where I enter the zip code and the corresponding city and state auto populate the two unbound boxes. I have placed the following event on the Zip combo box:
After Update:
Private Sub Zip_AfterUpdate()
City = DLookup("City", "tblZip", "Zip = '" & Me.Zip & "'")
State = DLookup("State", "tblZip", "Zip = '" & Me.Zip & "'")
End Sub
Everything works great until I actually enter or select the zip code for the combo box... the moment i hit the tab key, it auto populates the city and state with the wrong "city" and "state" information. Along with that, it doesn't seem to update when i go back and enter a different zip code... Hopefully this makes sense... I would appreciate any help with this.
Thank you.