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!

Linking combo boxes 2

Status
Not open for further replies.

PrintNET

MIS
Sep 30, 2002
30
US
I want to make it so that when the user selects an item in one box, which displays all items in a certain column, the other box would automatically change to another item in a set column on the same row. Any tips on how to do this?
 
In the <AfterUpdate> event of your first combo box, requery the second combo box.
 
heh... I guess I don't know how to do that either. Could you go into more detail?
 
Say you have two combo boxes (cbo1 and cbo2). After making a selection from cbo1, the potential values in cbo2 should change. To do this, in the <AfterUpdate> event property of cbo1, type the following: Forms!frmMyForm!cbo2.Requery or you could type this: me.cbo2.Requery.

HTH,

JK
 
I did what you said, even made a new form with combo boxes that matched your examples, and it didn't work correctly. When I select an item in the first combo box, the second remains blank. What could I have done wrong that would have caused this?
 
Is the value for cbo1 used as criteria for the potential values in cbo2?
 
The row source for the first combo box is:
SELECT [Sheet1 Query].[SKU] FROM [Sheet1 Query];
The row source for the second combo box is:
SELECT [Sheet1 Query].[Description] FROM [Sheet1 Query];
 
Try this for the row source of your second combo box: SELECT [Sheet1 Query].[Description],[Sheet1 Query].[SKU]FROM [Sheet1 Query]
Where [Sheet1 Query].[SKU]=Forms!frmYourForm!cbo1

This will tie the two combo boxes together, and using the requery command in the after update event of cbo1 should repopulate the potential values for cbo2.
 
Doe the Where and what follows it go in the row source as well?
 
hey print when you try this do you end up with a completely empty dropdown combo?
because im following you guys, and thats what
happened with me.
 
Let's assume I have a db with two tables. tblMake has the following field: Make. tblModel has the following fields: Make;Model.

Next, I have a form (frmAuto) with two combo boxes (cboMake and cboModel). The record source for cboMake is: SELECT [tblMake].[Make] FROM tblMake;

The record source for cboModel is: SELECT [tblModel].[Make], [tblModel].[Model] FROM tblModel WHERE ((([tblModel].[Make])=[Forms]![frmAuto]![cboMake]));

The possible values displayed in cboModel is directly related to cboMake. The two combo boxes are tied together by Make.

HTH,

JK
 
There is a much easier way to do this...

Say you have cboSelectname and cboSelectSS, use this on the On Click of cboSelectName

Private Sub cboSelectName_Click()
cboSelectSS.Value = SS_No.Value
End Sub


and this on cboSelectSS


Private Sub cboSelectSS_Click()
cboSelectName.Value = Last_Name.Value
End Sub


This should link the combo boxes
 
you didnt clarify what &quot;Last_Name&quot; and what &quot;SS_No&quot; was. Are they fields? if so from what tables are they from?
 
opps i think i misread the first post. Are you trying to make it like a menu?? For example the Start button in windows, then you select &quot;All Programs&quot;, then you select &quot;Assecories&quot;???

I thought you were just trying to get 2 combo boxes to have the same value.....sorry
 
well, i dont know if its necessarily a menu. But what im trying to do is: for instance, whenever a members name(member_id) is selected in one combo box, the companys(company_name) that he has worked for will be the only ones available in another combo box. So that the user doesnt have to scroll through every company, whether or not the member has worked for them or not.
 
Hmm... still not working. I have the data in one table if that matters. Here is what the row sources are set as currently...

cbo1:SELECT [Sheet1 Query].[SKU] FROM [Sheet1 Query];

cbo2:SELECT [Sheet1 Query].[SKU], [Sheet1 Query].Decription FROM [Sheet1 Query] WHERE ((([Sheet1 Query].[SKU])=[Forms]![frmMyForm]![cbo1]));

And thank you for all time you have spent trying to help me, Krameje.
 
PrintNET, I noticed you are missing a bracket around Description in the record source for cbo2.
 
Unfortunately that did not seem to fix the problem. You have any luck Rmck87?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top