Userform runs other subs when initialized

  • Thread starter Thread starter zipdog
  • Start date Start date
Z

zipdog

In trying to solve a problem with a user form, I began to suspect that
multiple subs were being triggered as soon as I showed the form. I put
a MsgBox into each sub in the code section of my userform, except for
Userform_Initialize. The form has two multicolumn list boxes, two combo
boxes, and three command buttons. Both listboxes and one combobox have
change event subs. When I initially call up this userform (from a
button in a Worksheet) the message box in the combobox change event sub
appears once, the message box in one listbox appears twice, and the
other appears three times! Is this normal behavior? Could this be why
my listbox selection values are being cleared unexpectedly?
I would really appreciate any help on this matter.
 
Thanks very much for responding. I have actually used both click and
change. Same effect. I have overcome the initial problem using an
event suppression solution from Dick Kusleika. Thanks, Dick! I also
changed the first procedure from initialize to activate, though I am
unclear what the difference is.

It still seems weird to me that change and especially click events fire
during Initialization. Even though I am please that I got my program
to work, I would still love to understand what's going on with
initialize, activate, and how they affect the values in listbox
controls.
 
It depends on what you are doing in the Initialize and Activate events.

Using a boolean public variable is useful in many cases (but not all) to
block events from running.
 

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

Back
Top