Why On Click event of a checkbox doesn't respond? (1 Viewer)

deletedT

Guest
Local time
Today, 02:17
Joined
Feb 2, 2019
Messages
1,218
I have a form with a crosstab query as its source. The query and the form's data is un-editable.
I want to run a function when I click on a check box on this form. But clicking the checkbox doesn't fire the event. I added a stop, a msgbox and a break point to the first line of the code, but nothing happens. Apparently the on click event is not triggering the function.
If I add the same function to on Double Click event everything is fine. The function is triggered and does what it's expected to do.

How can I run a function by on Click event of a checkbox on a form with un-editable record source?

No need to say how I appreciate any kind of advice.


Edit : I had to strip off a lot of controls and the code behind them. So the form may seem a little strange. It's just for the sake of testing.
 

Attachments

  • Database10.accdb
    548 KB · Views: 211
Last edited:

Isaac

Lifelong Learner
Local time
Yesterday, 18:17
Joined
Mar 14, 2017
Messages
8,792
The only thing that first came to my mind was whether or not you might have any controls, labels, borders, sizing, special effects, etc., which essentially appear to be "interrupting" the checkbox truly accepting the Focus and considering itself Clicked. The fact that it DOES get to this point after a second click reinforces this theory, for me at least. Can you check from the standpoint of anything that might be messing with getting a top layer focus - like set an OnGotFocus event w/a breakpoint on ANY surrounding controls, so you know for sure THEY aren't accepting the focus the first time you believe the checkbox is?
Even the a checkbox's own label can end up being placed almost practically over the checkbox it's so close.
 

deletedT

Guest
Local time
Today, 02:17
Joined
Feb 2, 2019
Messages
1,218
One click on the checkbox sets the focus on the checkbox. I can say it by the rectangle that appears around the checkbox after one click. So I don't think there's anything there to prevent the checkbox focus.

If I add the function to on focus, the function is triggered and executes. So nothing's wrong there. (I think)

the form is continuous and the labels are located in the header.

Thanks anyway.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:17
Joined
Mar 14, 2017
Messages
8,792
Can you post a db with just the form?
 

deletedT

Guest
Local time
Today, 02:17
Joined
Feb 2, 2019
Messages
1,218
The back end is sql server.
It takes a while to manage the local tables and the crosstab query with a limited data set.
Give me a little time.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:17
Joined
Mar 14, 2017
Messages
8,792
Understood. Hopefully this problem might be re-producible without any data at all - that's what I was hoping for anyway if we got lucky.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:17
Joined
Oct 29, 2018
Messages
21,499
Hi. Just a thought, but maybe try using the AfterUpdate event instead.
 

deletedT

Guest
Local time
Today, 02:17
Joined
Feb 2, 2019
Messages
1,218
Hi. Just a thought, but maybe try using the AfterUpdate event instead.
The recordset is not editable. So the checkbox never get updated. ( I believe. But will test it too. wait)


Edit : @theDBguy As I had guessed, the function is not triggered because the checkbox is not updated.
thanks anyway.
 
Last edited:

deletedT

Guest
Local time
Today, 02:17
Joined
Feb 2, 2019
Messages
1,218
Understood. Hopefully this problem might be re-producible without any data at all - that's what I was hoping for anyway if we got lucky.
I could reproduce it in another database too.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:17
Joined
Mar 14, 2017
Messages
8,792
As soon as I read dbGuy's response, I humbly remembered that I don't think I have ever (successfully) used the Click event of a checkbox...I would use AfterUpdate. Would this work for you?
 

deletedT

Guest
Local time
Today, 02:17
Joined
Feb 2, 2019
Messages
1,218
As soon as I read dbGuy's response, I humbly remembered that I don't think I have ever (successfully) used the Click event of a checkbox...I would use AfterUpdate. Would this work for you?
As I explained above, the checkbox doesn't get updated because the source is a cross tab query. If the checkbox doesn't update, its on update event is not fired.
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:17
Joined
Mar 14, 2017
Messages
8,792
I apologize. I missed the fact that the checkbox itself was actually a bound control with an individual recordsource.
Will post back if I come up with anything...all I can think of is to skip the checkbox's apparently unavailable Click event and overly a label or something?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:17
Joined
Oct 29, 2018
Messages
21,499
The recordset is not editable. So the checkbox never get updated. ( I believe. But will test it too. wait)


Edit : @theDBguy As I had guessed, the function is not triggered because the checkbox is not updated.
thanks anyway.
I see. Will this work?

PS. I only did the P column.
 

Attachments

  • Database10.zip
    37.9 KB · Views: 305

deletedT

Guest
Local time
Today, 02:17
Joined
Feb 2, 2019
Messages
1,218
I see. Will this work?

PS. I only did the P column.
Very clever. never thought of that.
While I will use this for my database, but my intention of posting this question mostly was understanding why on-click event is not fired, even if when I'm clicking the check box.

Million thanks for your time.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:17
Joined
Oct 29, 2018
Messages
21,499
Very clever. never thought of that.
While I will use this for my database, but my intention of posting this question mostly was understanding why on-click event is not fired, even if when I'm clicking the check box.

Million thanks for your time.
TBH, I may have an idea, but I can't really say for sure either. The way I look at bound controls (mostly textboxes) is that it doesn't really make sense to use (or have) a Click event. If I want something to happen when the data was changed, I'd use the On Update events. If I want something to happen when the textbox gets the focus, I'll use the On Focus event. Using the Click event doesn't work if the user doesn't use the Mouse.

Anyway, that's my non-answer to your question. Since your form's data is read only, it seems clicking on the Checkbox attempts to update the data more than just "clicking into" the box. So, I guess, you get the error warning, in priority over any event that should happen.

Just my 2 cents...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 20:17
Joined
Feb 28, 2001
Messages
27,243
My question is whether the "click" event fires if you set the focus on the checkbox and then press the SpaceBar?
 

strive4peace

AWF VIP
Local time
Yesterday, 20:17
Joined
Apr 3, 2020
Messages
1,002
hi @Tera

checkboxes are slow anyway and maybe Click doesn't work because it isn't editable. How about putting a transparent command button on top of it?
 

Users who are viewing this thread

Top Bottom