vpager
10-30-2008, 10:00 AM
Best to explain my question with examples:
Place a listbox on a userform. Add the following code to the userform to add some entries to the listbox and set a click event for the listbox to display a message with the TypeName of the clicked control.
Private Sub UserForm_Initialize()
For r = 1 To 6
ListBox1.AddItem r
Next r
End Sub
Private Sub ListBox1_Click()
MsgBox (TypeName(UserForm1.ActiveControl))
End Sub
Display the userform.
Click an entry in the listbox and message displays with "ListBox"
So far so good.
Second example:
Place a multipage on a userform.
Add a listbox to the multipage.
Add the same code as above.
Display the userform.
Click an entry in the listbox and the message displays "MultiPage" instead of "ListBox"
The same thing happens with any control object placed within the multipage.
But I am trying to identify when someone has clicked on a listbox control.
Any suggestions?
Before you post:
1. This is for the purpose of adding mouse scrolling to the listbox. So a listbox event is not available.
2. The listbox must remain on the multipage.
Thanks
Mike
Place a listbox on a userform. Add the following code to the userform to add some entries to the listbox and set a click event for the listbox to display a message with the TypeName of the clicked control.
Private Sub UserForm_Initialize()
For r = 1 To 6
ListBox1.AddItem r
Next r
End Sub
Private Sub ListBox1_Click()
MsgBox (TypeName(UserForm1.ActiveControl))
End Sub
Display the userform.
Click an entry in the listbox and message displays with "ListBox"
So far so good.
Second example:
Place a multipage on a userform.
Add a listbox to the multipage.
Add the same code as above.
Display the userform.
Click an entry in the listbox and the message displays "MultiPage" instead of "ListBox"
The same thing happens with any control object placed within the multipage.
But I am trying to identify when someone has clicked on a listbox control.
Any suggestions?
Before you post:
1. This is for the purpose of adding mouse scrolling to the listbox. So a listbox event is not available.
2. The listbox must remain on the multipage.
Thanks
Mike