What is the code for checking or unchecking a checkbox?

  • Thread starter Thread starter Dave R.
  • Start date Start date
D

Dave R.

I have a form I'm working on. I have added a checkbox which I want to use to
change the value of a field. Actually, I have 3 separate checkboxes, all
working on one field (setting the field value to 1, 2, or 3 depending on
which checkbox is checked). The reason for using 3 separate checkboxes is to
make it appear similar to a paper form that's being used.

In the coding, my question is how to get the value cleared from the field if
the checkbox is unchecked? The way it's (not) working now, is I can check
the box and the field changes to 2, however when I uncheck the box, the
field still says 2.

Here is what I'm using

Private Sub Check69_Click()
HemoTested3 = 69
End Sub


Many thanks.
 
Dave,

In a macro, you would use a SetValue action. However, you are not using
a macro, you are using a VBA procedure. The code you posted so far is
difficult to understand, as we don't know what Check69 is and we don't
know what HemoTested3 is and we don't know the significance of the value
69. It appears that you are using an Option Group which contains your 3
checkboxes. Once an Option Group has one of the checkboxes ticked, you
can't "untick", you can only select one of the others, but there will
always be one of then checkboxes ticked. One simple way to clear the
checkboxes is to put a little Command Button alongside the Option Group,
with code on its Click event the equivalent of this...
Me.NameOfYourOptionGroup = 0
 
Hi Steve, thanks for your reply. I ended up discovering/using option group
for it's built in "one or the other" function (I was originally planning to
use separate checkboxes..) . Thanks for the code on clearing that option
group though, that will be handy.
 
Back
Top