how to avoid an onchange event from being triggered by a code execution?

  • Thread starter Pablo Cardellino
  • Start date
P

Pablo Cardellino

Hi,
I have a multiselect list within a form and its onchange event runs a sub.
In some cases, when the list changed because of the user to have checked an
item, unchecks a list item, the sub unchecks another item, and this can
throw the script into an infinite loop.

How could I avoid the execution of the onchange sub when the onchange event
is triggered via script?

Thanks in advance,

Pablo
 
M

Manfred F

Hi Pablo,

Pablo Cardellino said:
How could I avoid the execution of the onchange sub when the onchange event
is triggered via script?

you need a synchronization between your event-procedures and your script.
This can be done via a global variable (e.g. called gEventsLocked) or, in a
more elegant way, by defining and using an appropriate attribute in your
eventhandler class. Your script then could inhibit and release event
processing.

Regards,
Manfred
 
P

Pablo Cardellino

Thanks, Manfred,
the first option, using a global variable, was what I did yesterday, and
it is working fine, but it doesn't really seem too much elegant.
or, in a
more elegant way, by defining and using an appropriate attribute in your
eventhandler class. Your script then could inhibit and release event
processing.

I didn't understand how this could be done, but it is my fault: I don't
even know what an eventhandler class is. The event I'm talking about is
OnChange, linked to a listbox.

Thanks,
Pablo

--
Pablo Cardellino
Florianópolis, SC
Brazil


Manfred F escribió:
 
M

Manfred F

Hi Pablo,

Pablo Cardellino said:
Thanks, Manfred,
the first option, using a global variable, was what I did yesterday, and
it is working fine, but it doesn't really seem too much elegant.

I assume, you are using a listbox control on a userform. So, the userform's
code is your eventhandler. Just define a public property "ChangeLocked" for
the userform and set/reset it from your script to block the change callback.

Regards,
Manfred
 

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