Checkbox: Problem with OnClick

wilf123

New member
Local time
Today, 15:41
Joined
Feb 17, 2014
Messages
9
Dear Access Experts,

I have noticed this problem before.
In a subform I have two checkboxes. One bound to a field.
One unbound and prefilled by a function: =f()

Both checkboxes have onclick-events attached, but the event of the unbound checkbox is not fired any more as soon I add the "=f()" expression as data source.

Please look at the sample attached.
Can anybody tell my why this happens?

Thanks very much in advance, regards, W
 

Attachments

Can anybody tell my why this happens?
it is because you have added =f() which makes it a calculated control which cannot be edited
 
Hi CJ_London,

Thanks for your answer, I have modified the little sample database.

I have now:
chk: checkbox bound to a field.
chk2: checkbox unbound.
abc: textbox bound to a field.
abc2: textbox unbound.

All 4 fields have onclick events.

After prefilling chk2 and abc2 with function: =f(), =f2()
clicking chk2 will not fire the corresponding event, but clicking abc2 will.

-------------------------

Being a "calculated control" can't be the reason.
The problem occurs with the checkbox but not with the textbox.
And after all why shouldn't "calculated controls" have onclick events?

Regards, W
 
Oh, no. You are right. Just found:

office.microsoft.com/en-us/access-help/create-a-calculated-control-HA010108354.aspx

See:

"For example, if you place a check box control on a form and then enter an expression in the Control Source property of the check box, you can no longer select or clear the check box by clicking it. ..."

But I'm still looking for a way around that limitation.
 
I think I found a solution. Instead of the OnClick-event I use the MouseUp-Event.
The message "Control can't be edited; it's bound to the expression your expression." still appeared in the status bar, but setting active=no locked=yes for that control got rid of that message. Objections?
Now I can execute code, whenever the user clicks the checkbox.

Update:
It works! But property "active" must be "yes".
 
Last edited:

Users who are viewing this thread

Back
Top Bottom