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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically update text box from combo box?

Status
Not open for further replies.

Kingsteveiv

Technical User
Oct 8, 2001
20
US
I have 2 tables that are unrelated.

Table 1 - Address

Location / Address / City / State
AA 1234 Denver CO
BB 5678 Chicago ILL

Table 2 - Route

Stop 1 / Stop 2 / Stop 3 / Dist

in order to fill the fields in table 2 (stop 1, stop 2, stop 3), i created a form, based on table 2, that imputs the data into the stop 1, stop 2, stop 3 fields of table 2 according to a combo box that pulls information from the location field of table 1. my question is, if on the form when i select the location from a combo box, how can i get it to automatically input the addresses of the location selected from the combo box into the form for a caluculation for DIST in table 2. I do not need the address to be in table 2, i just need the DIST calculation.

I cant seem to do this with a query since neither table has any related fields. Please help!!!

 
You need to create an unique primary key field in table1 then add a foriegn key in table2. that will link the tables together this will also create a one to many relationship. so what happens if you pull down chicago from the combobox it will show more than one record, in datasheet view, (if you have more than one route) and give your distances. After you create your keys in your tables. you nee to create the relationships. then on the AfterUpdate() of the combobox put this code

Dim rs As Recordset

Set rs = Me.Recordset.Clone
rs.FindFirst "[city] = " & Me.ComboBox
Me.Bookmark = rs.Bookmark

HTH

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top