New Year Quiz!!

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 06:43
Joined
Jul 9, 2003
Messages
16,719
1) - Which Controls Click Events cannot be disabled?
 
Last edited:
What do you mean by disabling an event
 
As in:-

Me.mycontrol.enabled = false

Update:-

The control, mycontrol has an on click event and it cannot be disabled. Well, I haven't found out how to disable it....

Update 2

I've found two controls where this applies..
 
Similar to how you can't lock a command button as explained in this thread:-

 
Labels have a click (and a double-click) but cannot be disabled since they have no data entry ability.

The same is true for Rectangle controls.
 
That's it Richard. Except in the case of an attached label. If a label is attached to a control it doesn't have an on click event of its own, clicking on an attached label causes it to implement the on click event of the control it's attached to, and that can be disabled.

Something similar occurs with an option button. A button in an option group frame has different properties to one in a frame.
 
1) - Which Controls Click Events cannot be disabled?
The wording of this question is misleading. You are not disabling the click event (nor any other event). You are disabling the control, which as a "side effect" also causes that the events cannot happen any more.
 
As in:-

Me.mycontrol.enabled = false

Update:-

The control, mycontrol has an on click event and it cannot be disabled. Well, I haven't found out how to disable it....

Update 2

I've found two controls where this applies..
Gotcha. Well, setting the Enabled property to false is very different than somehow disabling the entire click event... Two different things
 
Labels have a click (and a double-click)
It's still a mystery for me why I can not use on double click event of a label/button when I have a code for its on click event.
If I can not use both events, what are they good for?
 
Last edited:
Then the correct answer is: All control's!

Nope - for unattached labels and rectangles, you cannot disable them in the first place. Not all controls fall into the "can be Enabled" category but the two I named DO have essentially permanent OnClick events.
 
Nope - for unattached labels and rectangles, you cannot disable them in the first place.
:oops:No, no, no. Things are getting mixed up here. - Sorry, if it was me. I feel slightly challenged with negating negative statements about all, any, or every control.

What I tried to say is: All controls' click events cannot be disabled.
Or more concise: No control's click event can be disabled.

The rationale is: By setting a control's Enabled property to False you do not disable the click event (or any other event). You just put the control in a state that prevents (aka "makes it very difficult for") the user to perform an action that would trigger the event. The event itself however is not "disabled".
 
You just put the control in a state that prevents

I see what you mean.

The first thing to remember is, there isn't a control on the screen, there are only pixels. When you click on a pixel which is part of the control image, most likely the code calculates the boundaries of the control and identifies that the pixel is within them. (A guess, but someone will know the truth) If the control is "Not Enabled" I think that's an important distinction.... Then it's not necessary to run any of the events associated with it. As a programmer of the fundamental access structure that would make much more sense than trying to disable each individual event ...
 
:oops:No, no, no. Things are getting mixed up here. - Sorry, if it was me. I feel slightly challenged with negating negative statements about all, any, or every control.

What I tried to say is: All controls' click events cannot be disabled.
Or more concise: No control's click event can be disabled.

The rationale is: By setting a control's Enabled property to False you do not disable the click event (or any other event). You just put the control in a state that prevents (aka "makes it very difficult for") the user to perform an action that would trigger the event. The event itself however is not "disabled".

I agree - this is why I was originally confused.

On a very technical level, in my mind I am thinking to myself that the Enabled property has nothing to do with the Click event. Changing one will have zero effect on the other - directly.

However, practically speaking, I acknowledge they are related by usage and consequences.

I had just never heard the Enabled property referred to as the 'enabling or disabling the click event'.
 
The essence of the question is that if you want to lock down your Form so that the user can't do anything, typically a routine to "Lock ALL Controls" and your Form has "Unbound Labels" with a functioning "On Click Event" then you cannot loop through the Controls Collection and disable ALL the Controls. You CANNOT prevent an unbound label click event from working. A typical case would be a form/subform in datasheet view with labels at the top to sort the columns. I used the word "cannot", past experience has taught me that this is not a good idea!
 
most likely the code calculates the boundaries of the control and identifies that the pixel is within them.

Yep, but not "most likely" - more like "exactly."

Take a look at the MouseMove event...


If you want to find the control, it is basically a loop through ALL controls comparing the X and Y location returned by the MouseMove to the (Top, Top+Height) and (Left, Left+Width) for each control. Then you can sense the state of the mouse buttons. This is how "mouseover" things happen, like when you are on a VBA page and hover the mouse over a variable, it can show you the variable.

There are also the MouseUp/MouseDown events...


That loop I mentioned is how Access itself decides that you have clicked on a control. A click in the case of controls has three events that fire in sequence... MouseDown (over the control), MouseUp (over the control), Click (of the selected control)
 

Users who are viewing this thread

Back
Top Bottom