how to set the check box's checked/unchecked value to different value?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Does anyone know how to set the Check box or option button's value? In Access database, the default checked value(yes) is -1, and the default unchecked vaulue(no) is 0. I wanna change the checked value to 1, and unchecked value to -1. How to do that?

Thanks!
 
Flora,

You can't control the values used by a Yes/No data type field. If you
want to use different values in another context, you will need to make a
calculated field in a query, or a calculated control on your form or
report, something like this...
IIf([YourYesNoField]=0,-1,1)
 
Hi,

Does anyone know how to set the Check box or option button's value?
In Access database, the default checked value(yes) is -1, and the
default unchecked vaulue(no) is 0. I wanna change the checked value
to 1, and unchecked value to -1. How to do that?

Thanks!

Is the Check Box used as stand-alone control, or is it used within an
Option Group as a selection control?

1) As a stand-alone True/false control?
Why would you want to. Why does it matter? You can't!

A Check Box is either True, Yes, or On (-1) or False, No, or Off (0).

If working with the -1 value is creating a problem, let us know what
the problem is and perhaps we can help with that.

2) Used as a control within an Option Group (instead of the usual
radio buttons)?
Set the Check control's Option Value to what ever you want.
The Option Group will get it's value from the selected control's value
within the group, i.e. 1, 2, 3, etc.
 
Is the Check Box used as stand-alone control, or is it used within an
Option Group as a selection control?

1) As a stand-alone True/false control?
Why would you want to. Why does it matter? You can't!

A Check Box is either True, Yes, or On (-1) or False, No, or Off (0).

If working with the -1 value is creating a problem, let us know what
the problem is and perhaps we can help with that.

2) Used as a control within an Option Group (instead of the usual
radio buttons)?
Set the Check control's Option Value to what ever you want.
The Option Group will get it's value from the selected control's value
within the group, i.e. 1, 2, 3, etc.

To be slightly pedantic, a "standalone" checkbox has a third possible
state - Null, which displays as a grey background. You can only see or
use this state in an checkbox whose Triple State Property is set to
True (default is False), but is can be quite useful for recording N/A
or "no answer" responses to questionnaires. Interestingly, a checkbox
bound to a Boolean field cannot be Triple State, since an Access
Boolean field cannot have a Null value (pace Codd), but you can bind a
Triple State checkbox to an integer field and treat its contents like
a Boolean (except that it may be null).
Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Back
Top