Checkbox and continuous forms

exaccess

Registered User.
Local time
Today, 06:08
Joined
Apr 21, 2013
Messages
287
Hello to All,
I have a continuous form with multiple records displayed like a table one record per row. On each row there is a check box. The program will run though the checkboxes to take some action based on the value of the checkbox. How do I address the contents of the checkbox? Can someone give some example code please. Thanks.
 
Your question is kind of vague. Plus this should be posted in the code section.

If you want to refer to check boxes, you refer to them like any other control: Me.ControlName.

In Access VBA check box values are -1 for yes and 0 for no, I think. I don't use check boxes in Access because I can never remember the values. In normal VB it would just be true or false (checked or unchecked) which I think is better, not that this is relevant to your question.

Anyway, an example would be:

Code:
If Me.ControlName = 0 Then
Something happens
Else:
Something else happens
End If
 
Your question is kind of vague. Plus this should be posted in the code section.

If you want to refer to check boxes, you refer to them like any other control: Me.ControlName.

In Access VBA check box values are -1 for yes and 0 for no, I think. I don't use check boxes in Access because I can never remember the values. In normal VB it would just be true or false (checked or unchecked) which I think is better, not that this is relevant to your question.

Anyway, an example would be:

Code:
If Me.ControlName = 0 Then
Something happens
Else:
Something else happens
End If

The same in VBA
Code:
If Me.ChkName then ' the checkbox is checked
......
Else ' the checkbox is unchecked
.....
End IF
 
Myrtle,

Yes, you are right about the values. I prefer to use the constants True and False so that there is no question.
True = -1
False = 0
However, there is a little gotcha to watch out for. Anyone using checkboxes should be made aware of this. There's a Property called Triple State which can cause headaches. This third state is Null and doesn't apply if the checkbox is bound to a Yes/No datatype field. (It only applies when the control is either unbound or bound to a number field.) I often use unbound checkboxes on forms and typically set the Triple State = No and the Default Value = False.

Triple State has its usefulness. In the Yes/No world, the third state would be Undecided or Not Yet Answered. It is represented by a gray box rather than a white box or a checkmark. If one uses this third state to represent "Undecided" for example, you run the risk of confusing it with the not yet answered or no response values.

I prefer to have a known default value (i.e. False) until a user actively changes it.

_________________
Regards,
Marvin M :cool:
Windows 7 Professional, MS Access 2007/2010
Windows 8 Professional, MS Access 2013
----------------------------------------------------------------------------------------------------------------
If my post has helped you, please click the scales or click the 'Thumbs up'. Thanks!
----------------------------------------------------------------------------------------------------------------
 

Users who are viewing this thread

Back
Top Bottom