Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MultiSelect Listbox AfterUpdate Event?

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
0
0
I am trying to use a MultiSelect Listbox, & capture the input by using the
AfterUpdate event. Trouble is, the AfterUpdate event does not occur if the
Listbox is set to allow multiple selection...


Steps to replicate behaviour:

Add a UserForm (UserForm1), & add a single Listbox to the form (Listbox1).

Add the following code to the form module:
Option Explicit

Private Sub ListBox1_AfterUpdate()
MsgBox "Event Fired!"
End Sub


Private Sub UserForm_Activate()
Dim i As Integer

For i = 0 To 9
Me.ListBox1.AddItem i
Next i

End Sub


If ListBox1.MultiSelect = fmMultiSelectSingle then the event fires. However, if it is set to fmMultiSelectExtended or fmMultiSelectMulti it does not...


Any comments?

Cheers,

James Goodman MCP
 
Try using the "Click" event instead. It should fire after every selection. They you'll have to handle in code what to do incase the user isn't done clicking.

 
Hi James,

I could replicate your problem, .. except that even with the multiselect single it doesn't work!

However the MouseDown event works. Could you use that?

Nath
 
Excellent, I am not the only one! :)

What OS etc are you running? What program did you test it in?

I was beginning to think it was a design feature, but somebody running a beta-version of Word 2003 tried it & it worked as expected.

I will have a look at the mousedown event, although I find it annoying that the AfterUpdate event should work but doesnt...

James Goodman MCP
 
I'm on Windows NT4, and tried it on Excel 97 SR-2 (j) (didn't try on VB6 as this is a VBA forum).

I agree it is frustrating to have to use workarounds on things that should be working ... but I'm afraid that's often needed with our friend microsoft ...

Let us know how you are getting on.

Nath
 
Excellent thanks. I am running Win2K pro, with Office XP Developer SP2.

I actually noticed this phenomenon in ArcGIS 8.3 & managed to replicate it in Microstation V8.1.



James Goodman MCP
 
After support talks with Microsoft I can confirm this is an error with the Microsoft Forms 2.0 Object library.

Basically, the BeforeUpdate & AfterUpdate events do not fire by design with a multi-select listbox. The helpfile has not been updated to show this...

James Goodman MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top