Howto change the event function name (1 Viewer)

Micron

AWF VIP
Local time
Today, 16:41
Joined
Oct 20, 2018
Messages
3,478
(i.e. all the label.click events point to the same function) without having a routine for each one. I really don't want 85 separate functions mostly doing the same thing.
@MajP; This is, as you say, exactly how I took it and my posts followed that line of thinking. In a perfect world, the questions asked would always be technically accurate in the terms used as well as totally unambiguous. Obviously your approach would make more sense if it still satisfied the requirements. FWIW, I know from as far back as version 2003 that this technique, as well as queries, custom menus and toolbars could only call functions. Yet the proverbial light bulb moment never happened in this case.

My suggestion would be to let this go and not use the poor OP's thread to further this type of discussion, but use PM's instead.
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 15:41
Joined
Feb 28, 2001
Messages
27,183
Not that it is of particular significance, or maybe it IS important, but remember: If you are running a Macro and it contains a RunCode action, the code you run from that context must ALSO be a function. You cannot directly execute a Sub via RunCode.

Unfortunately, this is one of those "features" that will forever remain unclear to us until and unless Uncle Microsoft allows the VBA compiler to show us the pseudo-code generated for Sub and Function calls so we could compare them. Because obviously, something about the Macro's RunCode and Event's =Function both require that the called item would be in function context.

Which leads me to a question for someone who is curious enough to actually check this. Normally, events are linearized. That is, an event cannot interrupt another event. That is why we have a call to DoEvents() in some cases - to allow other events to fire. So... if that function is used and has a non-trivial duration, can an event interrupt it? In other words, is a function when called from the Event trigger counted as an event? I don't know that and normally don't think it matters. Nor am I sure what either result of the experiment would show.

And before anyone talks about how errors can interrupt events, that's because an Error is signaled by a TRAP, not an EVENT, and has a different special context.

Just food for thought.
 

Users who are viewing this thread

Top Bottom