Two different type of Label? (1 Viewer)

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
Why Access offers two different type of labels?
An un-associated label in a form can fire 5 events : On Click - On Double Click - On Mouse Down - On Mouse Up - One Mouse Move.
But as soon as I associate a label with a control, all events are vanished.

The code remains under the object name (it doesn't move to General in VBE).

Is there any way to fire a function for an associated label?

thank you.

Edit :
This is what I'm trying to do:
1- Users are allowed to click either the checkbox or its label to tick/untick the option.
2- Run a function with any events of check box or its label without changing checkbox state.

I'm terribly sorry for the confusion I caused.
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 15:23
Joined
Jul 9, 2003
Messages
16,244
Is there any way to fire a function for an associated label?

Well yes, but I think you already know this. You fire the event from the control that the label is attached to. It has the same events as the unattached label would have had...
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 15:23
Joined
Jul 9, 2003
Messages
16,244
If you want a text box to have a set of events of its own and you wanted a separate set of events in the attached label. One solution would be to make an invisible/transparent command button and place that over the label, add the events to that.
 

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
Well yes, but I think you already know this. You fire the event from the control that the label is attached to. It has the same events as the unattached label would have had...
I can not.
If the control is a checkbox or an option box, before on click, the control state changes.

Actually I need to use both On Click and On Double Click events of a checkbox.
Since Access doesn't allow using both of these events for any control, I was trying to use the label's events.

Thanks for your advice though.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:23
Joined
Oct 29, 2018
Messages
21,358
Hi. I guess there are two types of labels, so that you can use them for two different purposes. What is your current situation that you need to use the events of an attached label?

Edit: Oops, too slow. Looks like you already answered my question.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:23
Joined
May 7, 2009
Messages
19,169
for associated label, i think it inherit some of the textbox event.
if you add double_click event to the textbox, if you double click the
label instead, the code will fire. (the two becomes one?)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 15:23
Joined
Jul 9, 2003
Messages
16,244
Since Access doesn't allow using both of these events for any control, I was trying to use the label's events

See my tip on adding an invisible command button...
 

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
If you want a text box to have a set of events of its own and you wanted a separate set of events in the attached label. One solution would be to make an invisible/transparent command button and place that over the label, add the events to that.
I have a form with a lot of options (mostly check boxes and option boxes) to control the output of a report.
Based on the users request, the previous developer has used associated labels to ease selecting/deselecting the options.
It's much easier to click a control when it's wider (checkbox width + its label width)

If I cover the label with a button, I think I have to solve a problem that has been solved.

See my tip on adding an invisible command button...

Sorry. I was typing.
Again thanks for your advice.
 

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
For now I removed the associated label, added a button (per @Uncle Gizmo's suggestion)
The button's on click event, changes check box's state and run the function I need.

This works for now, But I'm all ear for any other solution.

Again thanks for all your advices.

Edit : it doesn't do What I want. Still waiting for some advice.
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 08:23
Joined
Oct 29, 2018
Messages
21,358
For now I removed the associated label, added a button (per @Uncle Gizmo's suggestion)
The button's on click event, changes check box's state and run the function I need.

This works for now, But I'm all ear for any other solution.

Again thanks for all your advices.
Hi. Glad to hear you got it sorted out. However, I am not sure I understand the situation completely. Why was there a need to detach the label? Are you now using the Click or Double-click event of that label to do something else? If so, where did you place the transparent button (over the label)?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:23
Joined
May 7, 2009
Messages
19,169
???same???
the associated label click event is same as that of the checkbox.
so you only add code to the checkbox click event to call your function.
 

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
Hi. Glad to hear you got it sorted out. However, I am not sure I understand the situation completely. Why was there a need to detach the label? Are you now using the Click or Double-click event of that label to do something else? If so, where did you place the transparent button (over the label)?
???same???
the associated label click event is same as that of the checkbox.
so you only add code to the checkbox click event to call your function.
Sorry, The solution I tried above, doesn't do what I need. ( I edited my post )
It seems that I'm confusing myself and all who are trying to help

This is what I'm trying to do:
1- Users can click either the checkbox or its label to tick/untick the option.
2- Run a function with any events of check box or its label without changing checkbox state.

thanks again.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:23
Joined
May 7, 2009
Messages
19,169
you can try,
i guess, the Transparent (or not transparent) button will do, since you don't want
the checkbox to change state.
also what is the event that need to be run and what is the code behind it.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:23
Joined
Oct 29, 2018
Messages
21,358
Sorry, The solution I tried above, doesn't do what I need. ( I edited my post )
It seems that I'm confusing myself and all who are trying to help

This is what I'm trying to do:
1- Users can click either the checkbox or its label to tick/untick the option.
2- Run a function with any events of check box or its label without changing checkbox state.

thanks again.
Hi. To help us think of a workaround, what will the function do and when would the user want to run it?
 

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
Hi. To help us think of a workaround, what will the function do and when would the user want to run it?
also what is the event that need to be run and what is the code behind it.
The checkbox decides if the report's result should be a list of all orders of this customer or only the un-delivered one.
The other function opens another form that shows the current situation of orders to see/edit current orders.

There are several other options (each one with a checkbox). That's why I tried not to crowded the form with a lot of buttons (one for each option).

Thanks again
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:23
Joined
Oct 29, 2018
Messages
21,358
The checkbox decides if the report's result should be a list of all orders of this customer or only the un-delivered one.
The other function opens another form that shows the current situation of orders to see/edit current orders.

There are several other options (each one with a checkbox). That's why I tried not to crowded the form with a lot of buttons (one for each option).

Thanks again
Hi. Thank you for the clarification. Are you saying if you can make the double click event work separately from the click event, that would be an acceptable solution?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:23
Joined
Feb 28, 2001
Messages
26,999
The difficulty here is that to me, it seems that you have contradictory requirements.

1- Users can click either the checkbox or its label to tick/untick the option.
2- Run a function with any events of check box or its label without changing checkbox state.

#1 requires the entire control to have uniform events.
#2 requires that the control have non-uniform events since any click will toggle the value.

EDITED BY The_Doc_Man to complete a thought.

At least, that is what I read.

Note also that if you have double-click engaged, you will also have single-click engaged - twice.


From this article,

When you double-click a command button, the following events occur in this order:

MouseDownMouseUpClickDblClickMouseUpClick

There IS the chance that you could detect a right-click or middle-click (3-button mouse) by detecting a MouseDown event. When you do, you can detect which button was used and whether someone was holding down SHIFT, ALT, or CTRL buttons (or more than one).


Just be aware that normally, Access will allow right-click menus to be used for some functions. (That is controlled from the ribbon: File >> Options >> Current Database.)
 
Last edited:

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
Hi. Thank you for the clarification. Are you saying if you can make the double click event work separately from the click event, that would be an acceptable solution?
For sure. That would be great.

thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:23
Joined
Oct 29, 2018
Messages
21,358
For sure. That would be great.

thanks
Okay, I recall doing it before by timing the two separate Click events, but I can't remember the actual code. I ended up using a Timer event to decide whether it was a click or a double-click by using a form variable. Although it was working during my testing, it wasn't very reliable. I'd say 90% of the time, it was working. The other 10%, the click event code was running when I wanted the double-click event code to run.

Instead, I found a more reliable approach by using the MouseUp event. So, would it be acceptable for your users to use the regular click event of the checkbox to do the normal stuff and then hold down the Shift or Ctrl or Alt key when clicking the checkbox to execute the other function? If so, I found that approach to be 100% accurate during my testing.
 

KitaYama

Well-known member
Local time
Tomorrow, 00:23
Joined
Jan 6, 2022
Messages
1,489
Okay, I recall doing it before by timing the two separate Click events, but I can't remember the actual code. I ended up using a Timer event to decide whether it was a click or a double-click by using a form variable. Although it was working during my testing, it wasn't very reliable. I'd say 90% of the time, it was working. The other 10%, the click event code was running when I wanted the double-click event code to run.

Instead, I found a more reliable approach by using the MouseUp event. So, would it be acceptable for your users to use the regular click event of the checkbox to do the normal stuff and then hold down the Shift or Ctrl or Alt key when clicking the checkbox to execute the other function? If so, I found that approach to be 100% accurate during my testing.
There's some hope there.
I will try and test the timer idea. If the result somehow satisfies the users we will go with that.
Otherwise I'll go with shift click or ctrl click.

I think I can manage the code.
Million thanks for the idea.
 

Users who are viewing this thread

Top Bottom