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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the 'value' of a grey check box? 1

Status
Not open for further replies.

jeffmoore

Programmer
Joined
Aug 29, 2003
Messages
301
Location
US
I have a form that when it is open the checkboxes appear in one of the three states; checked, not checked, or greyedout. The checkboxes are NOT triple stated. I need to be able to test (in vba) for the grayed out boxes. when i tried to look at the oldvalue for one of the greyed boxes it returns a zero.
Tia
Jeff
 
Thanks
I found out that for the checkbox to return NULL the box needs to be triple stated.
The above according to the vba help.
Well... when I triple stated the checkbox and then test for mycheckbox.oldvalue I still get 0.
I tried setting the default value to null, doesnt work.
i still get 0
There is next to no help in the vba help file on checkboxes.
So I'm still lookin...
TIA Jeff
 
Okay more info on the problem.
using a before update event I halt the code at the opening line and look at the properties for my checkbox.
BOTH the old value AND the present value are changed.
ie: the box was grey --> I click on it it is checked.
prior to the before update event both properties are null.
then BOTH are -1 during the before update event.
Any suggestions?
Jeff
 
Hi

Have you tried the obvious

If IsNull(chkMyCheckBox) Then
..etc
end if

???

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Just curious, why do you wish to test for the grayed out state? If your checkboxes are unbound and you haven't specified a default value, grayed out is how they will display when the form is opened, even if they're not triple-state. Post a little more info about what you are trying to accomplish and maybe we can advise you better.

Ken S.
 
First yes i have tried the obvious.
I have a form that is based on three tables with ref. integrety set.
when the form is diplayed (as a continuous form) there will be valid values for some of the checkboxes. these are the only checkboxes i want the user to be able to manipulate. If the check box is grayed out then there is no valid record in one of my associated tables and I get the error message form access stating that i cant add a record as there is no associated record in the primary table.
well if i get that error i have to close the form and reopen it to clear the error. I'd just like to trap any click on a checkbox with a null value.
I have look at the variables using the vba watch, and locals windows and the state of the checkbox is not what i beleive should be the predictable behavior.
I hope this explaination help.
Try building a form with one checkbox on it and put code in the OnEnter and OnBeforeUpdate events. Place a break in both events at the first line possible and set up a watch on chkbox.value and chkbox.oldvalue at both events
on the onenter:
both values are NULL
onthe the onbeforeupdate:
oldvalue = 0
value = -1
try it and help me understand
Thanks alot for your time
Jeff
 
Hi Jeffmoore,

If your tick box is there to indicate the presence of a record in a related table, then your database is not normalised, because the data includes redundant information.

Instead, why not put code in the BeforeUpdate event of the primary key do do a DLookup of a record in the related table - if it returns null then you can display a friendly error message and set Cancel to true; much nicer than Access built in error messages.

John
 
Hey, Jeff,

Why not give something like this a try in the checkbox's Mouse Down event...

Code:
If Me!chkMyCheckbox = True Or Me!chkMyCheckbox = False Then
    'process normally
    Else
        MsgBox "Nyah, nyah, you can't click me!"
        DoCmd.CancelEvent
End If

HTH...

Ken S.
 
THANK YOU EUPHER!!!
Nice and simple, I'm not sure I understand the root of the problem, but at this point I dont care!
Thanks to everyone for their input.
And if anyone figures out why the null test won't work or that bit about the events I worte about, Please post it
THanks again
jeff
 
I have recently seen in a book that the value of check boxes can be 0,1, and 2. One for unchecked,checked, and greyed. I can not remember exactly what value for each. I will try to get the exact name of the book and page number to help. I will try to post everything by tomorrow .

Tormented
 
According to the help file in access, the values for a checkbox are: -1,0,null which result in the visualization of checked, not checked, and gray.
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top