Several comboBoxes on a Userform

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.
 
M

merjet

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
 
M

mor.mic

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
 
M

merjet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top