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

Combo box to pull up info. for a selected item on the query list?

Status
Not open for further replies.

FunnyGuy

Technical User
May 26, 2003
19
CA
I have a pull down combo box in my form. when i select an item on the list of the combo box (from table called "Query builder-Structural Names", it display imperial names and metric names), i like it to retrieve all data for that particular item that's selected from the combo box list.

All the Data are in a table called "Structural Data" (Weight, Width, Lenth... etc.)

On the form i have a "text box" to display the current datas. The form now display the default data in the text boxes.

How do i get the combo box to let me select the item on the list and update the text box with the correct data for the selected item?

Advance "Thank you all
 
If I understand correctly you are using two different tables to get the data you need.


In the After_Update event of the combo box you will need to locate the record in your second table [Structural Data] that matches the stored value of the combo box and then populate the values in your text boxes. Make sure to lock or disable your text boxes so the user cannot change data.

It might be easier, though, to create a query that joins the two tables together. Then all you would have to do is update the text boxes on your form.

You might also place this query into the forms Data Source and then place the fields from the field list on your form. From there you could generate a lookup that then moves the record pointer in the forms recordset from your lookup control. This should then update the fields from the field list on your form. (Becareful to protect these fields as the data can be changed.)

I hope that gives you some insight, and I hope I did not give you anything confusing.



 
sorry, i have created a query builder in the form linking the tables "Data Names & Structure Data" in a relationship join. I have selected the join to "only include rows where the joined field from both tables are equal." So, how do i update the textboxes on my form?

again Thanks.
 
The example I just did linked quote header and detail table together in a query. I assigned that query to the record source of the form.

Next I created a combo box on the form and assigned that query to the row source property. (Make sure to hide columns you do not want listed in the combo box by modifying the control properties.)

I then placed text boxes on the form that will display data on the form.

In the After_Update event set the values of your text boxes by using the following code.

Code:
Me.txtCompanyName = Me.cboCompanySelect
Me.txtAddress1 = Me.cboCompanySelect.columnn(1)
Me.txtPhone = Me.cboCompanySelect.columnn(2)
Me.txtEMail = Me.cboCompanySelect.columnn(3)

That's a down and dirty way to do it. You may want to check the NorthWinds Sample Database Orders Form for additional information.

It will take some tweaking and error checking but it should work for you. If you have multiple detail records you will probably need to use subform(s) to display the additional records.

I hope this helps more. If not let me know.

Ascemt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top