dependent combobox

WJReid

Active Member
Joined
Jul 26, 2002
Messages
317
Hi All,

I would like to limit the list of one combobox, based on the value of another combobox e.g. Select a customer from the first combobox and have all contacts of that company appear in the second combobox. Can you tell me if this is possible.

Regards,

Bill
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
It is possible, and not all that difficult. But can you tell us a bit about your tables? You say select a customer from a combobox and then have all contacts from that company appear in the second combobox. Does the rowsource of the first combo contain customer AND company? Also, do you have a separate table with contacts, and is company also in that table?

Thank you,

Russell
 
Upvote 0
Hi Russell,

I have two tables, one with customer details and the other with customer contact details. Both tables have the customer ID in them. The company details that I was referring to is the customer contact details for that customer, I should not have said company, sorry.

Regards,

Bill
 
Upvote 0
So when you select the customer in one combo, you want the details in the other one? And the contact details has multiple rows per ID?
 
Upvote 0
Hi Russell,

What I have is a table for Sales Orders, joined to the Customers table by the CustomerID field. Then the Customers table is joined to the CustomersContacts by the CustomerContactID. Each Customer can have many sales orders and each customer can have many CustomerContacts.
Ideally, I would like to select a new Sales Order and Customer from a ComboBox and for the CustomerContact combobox to have all of the records from that customer.

I hope this clarifies it a little, Russell.

Regards,

Bill
 
Upvote 0
What I have is a table for Sales Orders, joined to the Customers table by the CustomerID field. Then the Customers table is joined to the CustomersContacts by the CustomerContactID. Each Customer can have many sales orders and each customer can have many CustomerContacts.
Ideally, I would like to select a new Sales Order and Customer from a ComboBox and for the CustomerContact combobox to have all of the records from that customer.
Ok, not sure what field you want to have in your second combobox, but basically you can base the Row Source of the second combobox on the first, something like:

Select [CustomerContact] From CustomerContacts Where [CustomerID] IN ([Forms]![FormName]![FirstComboName])

Then, add some code to the AfterUpdate event of the first cobmbobox, something like:<pre>Private Sub cboCompany_AfterUpdate()
Me.cboContacts.Requery
Me.cboContacts = Me.cboContacts.ItemData(0)
End Sub</pre>

And you can add something like this to the Form's Load or Open event so that you have a value in the first combo upon opening:<pre>Private Sub Form_Load()
Me.cboCompany = Me.cboCompany.ItemData(0)
End Sub</pre>

HTH,

Russell
This message was edited by Russell Hauf on 2003-01-17 11:57
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,537
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top