Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox value

Status
Not open for further replies.

kpetas

Programmer
Oct 19, 2006
11
ES
How can I get if a check box is checked or no with VBA code?
Thanks
 
For me, a checked CheckBox has a True value.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
However, just because it is NOT True does not mean it is False (and therefore unchecked) since Checkboxes are tristate, and may have the value NULL
 
1. FormField checkboxes are not TriState, and can not be set for such. Value is either True, or False.

2. ActiveX checkboxes CAN be TripleState, but by default are not TripleState. They must be explicitly set to be TripleState.

So unless the checkbox is an ActiveX control AND it has been explicitly set to be TripleState - True or False are the possible values.

Gerry
My paintings and sculpture
 
As usual, there are a number of ways to "check the checkbox."

This is the code I use for checking at the time when the box is checked:

Code:
Private Sub InLine_Click()
If Me!YourCheckBoxName Then
      'Code here for when box IS CHECKED
 Else
      'Code here for when box IS NOT CHECKED
End If
End Sub

To check when going to a new record (for doing things like changing the color of text if the box is checked, or making a control visible/unvisible depending on the checkbox):

Code:
Private Sub Form_Current()
 If Me!YourCheckBoxName Then
      'Code here for when box IS CHECKED
 Else
      'Code here for when box IS NOT CHECKED
 End If
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
If CheckBox1.Value = False Then GoTo NextProcedure

here is how i check the present status of a check box
checking for the status i am looking for.

hope it makes sense.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top