Preserve setting in a check box

G

Guest

Hello,
I want to ensure that users do not delete a tick in a check box as they tab
through a form. Once the box has been ticked (to show that we can claim back
tax on donations) I want the tick to be secure against accidentally removing
it. The field is used to run automatic tax reclaims and if the tick has
gone, we don't get the tax back!
Ideally I would like a little pop up window to say something like "Are you
sure you want to remove the tick from this box?", which they can respond to
with a 'yes' or 'no'.
I guess I need to insert some code into 'on exit' or 'lost focus' event.
PS there is already an [event procedure] in the 'on exit' property which
concerns entering a date in another field when the box is ticked.
Any help is much appreciated. I am a newbie to coding but slowly beginning
to understand it on a 'need to know' basis. Thanks.
 
G

Guest

I assume you are setting the focus to the date field or are you using an
input box to get the info and then placing this in the date field ?
Either way, you need to make sure the check box does not have the focus then
you could add this code within your 'if check box is ticked' section

[CheckBoxName].Enabled = False
 
J

Jeff Boyce

One approach would be to use the BeforeUpdate event and something like (your
syntax may vary):

If Me!chkYourCheckBox = False Then
If vbYes = MsgBox("Are you sure?",vbYesNo,"Confirming...") Then
Else
Cancel = True
End If
End If

Regards

Jeff Boyce
<Access MVP>
 
G

Guest

Hello Jeff... Your solution seems to be what I want, but I can't get past an
error message saying Compile error: expected Then or Go To. This is what I
placed in the BeforeUpdate code:

Private Sub Gift_Aid_Form_Received_BeforeUpdate(Cancel As Integer)
If Me!chk[Gift Aid Form Received]is False Then
If vbYes = MsgBox("Are you sure?", vbYesNo, "Confirming...") Then
Else
Cancel = True
End If
End If
End Sub

(Name of the control is 'Gift Aid Form Received')

It probably only needs tweaking a little. I've tried brackets, spaces and
new lines in various places but it still won't run. Can you offer any further
suggestion, please?
Thank you.

Jeff Boyce said:
One approach would be to use the BeforeUpdate event and something like (your
syntax may vary):

If Me!chkYourCheckBox = False Then
If vbYes = MsgBox("Are you sure?",vbYesNo,"Confirming...") Then
Else
Cancel = True
End If
End If

Regards

Jeff Boyce
<Access MVP>

ancient_hilly said:
Hello,
I want to ensure that users do not delete a tick in a check box as they tab
through a form. Once the box has been ticked (to show that we can claim back
tax on donations) I want the tick to be secure against accidentally removing
it. The field is used to run automatic tax reclaims and if the tick has
gone, we don't get the tax back!
Ideally I would like a little pop up window to say something like "Are you
sure you want to remove the tick from this box?", which they can respond to
with a 'yes' or 'no'.
I guess I need to insert some code into 'on exit' or 'lost focus' event.
PS there is already an [event procedure] in the 'on exit' property which
concerns entering a date in another field when the box is ticked.
Any help is much appreciated. I am a newbie to coding but slowly beginning
to understand it on a 'need to know' basis. Thanks.
 
G

Guest

Hi Jeff, Please ignore my earlier posting. I've tried it again (as shown
below) and it nearly does what I want. But I really only wanted the warning
to display if a tick was being removed from a check box, not when a tick is
put into an empty box as well. Is this possible, please?

Private Sub Gift_Aid_Form_Received_BeforeUpdate(Cancel As Integer)
If IsNull(Me![Gift Aid Form Received]) = False Then
If vbYes = MsgBox("Are you sure?", vbYesNo, "Confirming...") Then
Else
Cancel = True
End If
End If
End Sub

Thanks for your help.

Jeff Boyce said:
One approach would be to use the BeforeUpdate event and something like (your
syntax may vary):

If Me!chkYourCheckBox = False Then
If vbYes = MsgBox("Are you sure?",vbYesNo,"Confirming...") Then
Else
Cancel = True
End If
End If

Regards

Jeff Boyce
<Access MVP>

ancient_hilly said:
Hello,
I want to ensure that users do not delete a tick in a check box as they tab
through a form. Once the box has been ticked (to show that we can claim back
tax on donations) I want the tick to be secure against accidentally removing
it. The field is used to run automatic tax reclaims and if the tick has
gone, we don't get the tax back!
Ideally I would like a little pop up window to say something like "Are you
sure you want to remove the tick from this box?", which they can respond to
with a 'yes' or 'no'.
I guess I need to insert some code into 'on exit' or 'lost focus' event.
PS there is already an [event procedure] in the 'on exit' property which
concerns entering a date in another field when the box is ticked.
Any help is much appreciated. I am a newbie to coding but slowly beginning
to understand it on a 'need to know' basis. Thanks.
 
J

Jeff Boyce

Have you tried both "sides" of the If Then Else statement? If the condition
testing (=False) doesn't capture the event, try ...= True...

Jeff Boyce
<Access MVP>

ancient_hilly said:
Hi Jeff, Please ignore my earlier posting. I've tried it again (as shown
below) and it nearly does what I want. But I really only wanted the warning
to display if a tick was being removed from a check box, not when a tick is
put into an empty box as well. Is this possible, please?

Private Sub Gift_Aid_Form_Received_BeforeUpdate(Cancel As Integer)
If IsNull(Me![Gift Aid Form Received]) = False Then
If vbYes = MsgBox("Are you sure?", vbYesNo, "Confirming...") Then
Else
Cancel = True
End If
End If
End Sub

Thanks for your help.

Jeff Boyce said:
One approach would be to use the BeforeUpdate event and something like (your
syntax may vary):

If Me!chkYourCheckBox = False Then
If vbYes = MsgBox("Are you sure?",vbYesNo,"Confirming...") Then
Else
Cancel = True
End If
End If

Regards

Jeff Boyce
<Access MVP>

Hello,
I want to ensure that users do not delete a tick in a check box as
they
tab
through a form. Once the box has been ticked (to show that we can
claim
back
tax on donations) I want the tick to be secure against accidentally removing
it. The field is used to run automatic tax reclaims and if the tick has
gone, we don't get the tax back!
Ideally I would like a little pop up window to say something like "Are you
sure you want to remove the tick from this box?", which they can
respond
to
with a 'yes' or 'no'.
I guess I need to insert some code into 'on exit' or 'lost focus' event.
PS there is already an [event procedure] in the 'on exit' property which
concerns entering a date in another field when the box is ticked.
Any help is much appreciated. I am a newbie to coding but slowly beginning
to understand it on a 'need to know' basis. Thanks.
 
G

Guest

Thank you Jeff. I'm now happy with the result that it asks for confirmation
whether the box is ticked or unticked. Your help is very much appreciated.

Jeff Boyce said:
Have you tried both "sides" of the If Then Else statement? If the condition
testing (=False) doesn't capture the event, try ...= True...

Jeff Boyce
<Access MVP>

ancient_hilly said:
Hi Jeff, Please ignore my earlier posting. I've tried it again (as shown
below) and it nearly does what I want. But I really only wanted the warning
to display if a tick was being removed from a check box, not when a tick is
put into an empty box as well. Is this possible, please?

Private Sub Gift_Aid_Form_Received_BeforeUpdate(Cancel As Integer)
If IsNull(Me![Gift Aid Form Received]) = False Then
If vbYes = MsgBox("Are you sure?", vbYesNo, "Confirming...") Then
Else
Cancel = True
End If
End If
End Sub

Thanks for your help.

Jeff Boyce said:
One approach would be to use the BeforeUpdate event and something like (your
syntax may vary):

If Me!chkYourCheckBox = False Then
If vbYes = MsgBox("Are you sure?",vbYesNo,"Confirming...") Then
Else
Cancel = True
End If
End If

Regards

Jeff Boyce
<Access MVP>

Hello,
I want to ensure that users do not delete a tick in a check box as they
tab
through a form. Once the box has been ticked (to show that we can claim
back
tax on donations) I want the tick to be secure against accidentally
removing
it. The field is used to run automatic tax reclaims and if the tick has
gone, we don't get the tax back!
Ideally I would like a little pop up window to say something like "Are you
sure you want to remove the tick from this box?", which they can respond
to
with a 'yes' or 'no'.
I guess I need to insert some code into 'on exit' or 'lost focus' event.
PS there is already an [event procedure] in the 'on exit' property which
concerns entering a date in another field when the box is ticked.
Any help is much appreciated. I am a newbie to coding but slowly
beginning
to understand it on a 'need to know' basis. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top