Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql to automatically fill in form

Status
Not open for further replies.

taylornow

Technical User
Oct 16, 2000
90
US
Hello - I have a form with general info like address, city, yada yada yada. I have a combo box that appears when the person begins typing the city name and fills it in. I have a table that lists the counties, cities, and regions. What I want to happen is when the city is keyed in, the county and region automatically fill in. All my tries have failed and I am stuck. Can anybody kick me in the right direction? Thanks in advance.

Taylor
 
In the After Update event of the combo box perform a DLookup to get the appropriate values and place them in their corresponding controls like so:

MyCountyTextBox = DLookup("[County]","tblCities","[City]=[MyCityComboBox]")
MyRegionTextBox = DLookup("[Region]","tblCities","[City]=[MyCityComboBox]")

HTH Joe Miller
joe.miller@flotech.net
 
Okay - The control sourse on the form I am using is from a different table than the combo box for the cityname. The county that I need to pick up is from the same table that the cityname combo box came from. I use the DistinctRow command on the cityname combo box but how do I pull the county of residence field ( called countyname1 on the other table) depending on the selection from the cityname combo box? I tried the update but I must be incorrectly entering where the info needs to come from. The name of the field I want it to automatically fill in is called County of Residence. The field name from the table it is in is called CountyName1 and the table is City County.

Thanks in advance

Taylor
 
=DLookup("[CountyName1]","City County","[CityNameComboBox] = [CityName]")

HTH Joe Miller
joe.miller@flotech.net
 
Okay - I am following but where is the expression that tells it to go to the County of Residence field? Am I putting this statement in the Update field of the City ComboBox property part? Aughhhhhhh.

Thanks Taylor
 
County Of Residence = DLookup("[CountyName1]","City County","[CityNameComboBox] = [CityName]") Joe Miller
joe.miller@flotech.net
 
When I keyed it in and tried to enter a new person a message popped up saying the macro or macrogroup cannot be found. Am I just making this more hard than it is ?

Thanks for the upteenth time.

Taylor
 
Send me a copy of your db so i can have a look see..

Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top