Checking Check Box Status

T

Tatakau

I am trying to check the status of a check box in VB code - is the box on the
form checked, or unchecked?

Pseudocode... - if (DateCheckBox = checked) then

Also, on the side, what is the difference between something like
'Me.DateCheckBox' or just 'DateCheckBox' - what is this 'Me." stuff, and are
there any other prefixes that refer to other access objects?

Thanks,

Nick
 
G

Graham R Seach

Tatakau,

Check the control's values like so:
If Me.DateCheckBox = True Then

"Me" is a VB keyword that acts like an implicity declared object variable,
which means "the current base object". In a form, it means the form; In a
report it means the report; In a class, it means the class.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
A

Allen Browne

A check box has the value True, or False.

Therefore you can code:
If DateCheckBox = True Then
or just:
If DateCheckBox.Value Then

Me is a shortcut to the module of the form.
Example: If the form is named "Form1", then:
Me.DateCheckBox
is equivalent to:
Forms!Form1!DateCheckBox
through more efficient.
 
K

Klatuu

If an object is contained withing an object, you have to reference the object
in which it is contained.
forms!MyFormName!MyControlName is the same as Me.ControlName
Me is a "shortcut" way of refering to the current form or report.
MyControlName does not work, because Access doesn't know to which object it
belongs. You could have multiple controls with the same name in different
forms.
A Check Box will only return two values. True (-1) if it is checked or
False (0) if it is not checked. So, here are 3 ways you can look at that:

Checked = True
If Me.DateCheckBox = Checked Then
If Me.DateCheckBox = True Then
If Me.DateCheckBox Then
 
Top