derrickchanson
Technical User
I am trying to get an "address", "state", and "city" field to automatically fill in on a form based on the selection from a listbox called "site".
The "Site" field list comes from a separate table called "tbldistricts", which contain the matching address, city, and state for the site.
When I enter a site in the field the address, city, and state fields fill in automatically, but with the same information everytime, never changing.
Here is the code I entered for the "site" field:
Private Sub Site_Exit(Cancel As Integer)
Dim varAddress1, varCity, varState As Variant
Address1 = DLookup("Address1", "tblDistricts", "Site =[Site]"
City = DLookup("City", "tblDistricts", "Site = [Site]"
State = DLookup("State", "tblDistricts", "Site = [Site]"
If (Not IsNull(varAddress1)) Then Me![Address1] = Address1
If (Not IsNull(varCity)) Then Me![City] = City
If (Not IsNull(varState)) Then Me![State] = State
End Sub
Why are the address, city, and state not filling in properly?
Thanks
Derrick
The "Site" field list comes from a separate table called "tbldistricts", which contain the matching address, city, and state for the site.
When I enter a site in the field the address, city, and state fields fill in automatically, but with the same information everytime, never changing.
Here is the code I entered for the "site" field:
Private Sub Site_Exit(Cancel As Integer)
Dim varAddress1, varCity, varState As Variant
Address1 = DLookup("Address1", "tblDistricts", "Site =[Site]"
City = DLookup("City", "tblDistricts", "Site = [Site]"
State = DLookup("State", "tblDistricts", "Site = [Site]"
If (Not IsNull(varAddress1)) Then Me![Address1] = Address1
If (Not IsNull(varCity)) Then Me![City] = City
If (Not IsNull(varState)) Then Me![State] = State
End Sub
Why are the address, city, and state not filling in properly?
Thanks
Derrick