Default settings for check boxes

P

Pat Briggs

I need to be able to change the default setting for check boxes from -1 to 1
(or something else). Is there an easy way to do this? I'm not real
comfortable with VBA programming so keep it simple for me, please?
 
M

M Skabialka

In Design view in your table, set the default value to a value of 0 for
False, Off, No, etc, or -1 for True, On, Yes
1 is not an option.
Mich
 
K

Ken Sheridan

It could be done if you change the data type of the column to an integer
number. Then in a form put the following code in the AfterUpdate event
procedure of a check box bound to the column:

Dim ctrl As Control

Set ctrl = Me.ActiveControl

ctrl = Abs(ctrl)

This will set the value to 1 if its currently 0 and vice versa.

In the table design set the column's Required property to True (Yes) and its
DefaultValue property to 0.

Even though Access implements Boolean values as 0 and -1 the values of 0 and
1 in the column will still be recognized as Boolean FALSE or TRUE because a
TRUE is determined by virtue of being NOT FALSE, so any non-zero value is
TRUE. If you assign a Boolean TRUE to the column by means of code or an SQL
statement, however, the underlying value assigned would be -1, not 1 so if
doing this be sure to assign a value of 1 rather than TRUE.

Ken Sheridan
Stafford, England
 
Top