linking combo boxes

shrive22

Board Regular
Joined
Jun 10, 2002
Messages
120
I have two combo boxes that users can choose either customer# or customer Name from, what I want is that when they pick one the other combo box updates to the corresponding value that the user picked.

Im not quite sure how to do this?

thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Might be easier to have two columns in one combobox dropdown containing both pieces of information. To do this set your rowsource to the two fields, and change the Columns property to 2.
 
Upvote 0
If I do that then can the user still key in the values instead of selecting them with the mouse??


And is there anyway to have both fields show up in the box when they are selected???


thanks again
 
Upvote 0
Just as a quick test, set up a blank form, add two comboboxes both containing both your customer number and customer name. Hide the number in the first and the name in the second and make sure both are bound to the customer number. Then add this code, changing the cmbobox names as appropriate. Is this suitable?

Code:
Private Sub Combo0_AfterUpdate()

Me.Combo2.Value = Me.Combo0.Value

End Sub

Private Sub Combo2_BeforeUpdate(Cancel As Integer)

Me.Combo0.Value = Me.Combo2.Value

End Sub
 
Upvote 0
I tried your code i think that it gives me the same value in both boxes - not what i wanted.

i wanted the box to have the corresponding value. like if someone selected cust_no 100 then the correwsponding customer would be ABC corp
and have those values in the respective boxes.

thanks for the help though
 
Upvote 0
shrive22 said:
how do you hide the columns
??

Bring up the properties screen, make sure your column count is 2, set the column widths to something like 0cm;3cm for one, and 3cm;0cm for the other.
 
Upvote 0
I think a bigger issue here is what exactly are you going to do with the values inside these combo boxes - are you wanting either of these to be bound to a field in the form's recordsource? If so, you can simply run a filter on the form to get both of your boxes to show fields from the same record. If not, then the previous suggestion(s) should work for you.

-Russell
 
Upvote 0

Forum statistics

Threads
1,221,532
Messages
6,160,381
Members
451,643
Latest member
nachohoyu

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