Several comboBoxes on a Userform

  • Thread starter Thread starter mor.mic
  • Start date Start date
M

mor.mic

Hello

I have a Userform with 5 ComboBoxes names "ComboBox1" to "ComboBox5".

Each of them is loaded with the same data base.
When I make a choice in a Combo, I have to control the entry.
How can I make a routine to know which of the five has been selected and to
get the selection.

I tried to use a Class Module but unsuccesfully: Exit method doesn't
operate.

Thanks for helping me.
 
I have a Userform with 5 ComboBoxes names "ComboBox1" to "ComboBox5".
How can I make a routine to know which of the five has been selected and to
get the selection.

This should get you started. If c.ListIndex = -1, the ComboBox hasn't been
selected.
If the ComboBox has been selected, then c.Value will show the value.

HTH,
Merjet

Private Sub UserForm_Click()
Dim c As Control
For Each c In Me.Controls
If TypeName(c) = "ComboBox" Then
MsgBox c.Name & " " & c.ListIndex & " " & c.Value
End If
Next c
End Sub
 
Hi Merjet, thanks for your answer

Your proposal is right, but I don't use the Userform_Click event. I only
skip from one ComboBox to an other. My problem is to find which ComboBox has
just been used to verify if the selection is got from the data base or is a
new element. I must do that each time I leave a ComboBox.

Regards
Michel
 
Your proposal is right, but I don't use the Userform_Click event. I only
skip from one ComboBox to an other. My problem is to find which ComboBox has
just been used to verify if the selection is got from the data base or is a
new element. I must do that each time I leave a ComboBox.

Then move the code (w/o 1st & last lines) to another procedure where you do
want it.

HTH,
Merjet
 
Back
Top