[AccessD] Creating default false in yes/no field

Bill Benson bensonforums at gmail.com
Tue Aug 5 23:30:35 CDT 2014


I think it is also worth pointing out a corollary, that in a Yes/No field,
Access converts any non-zero integer update to -1. That is easily
demonstrated by these two steps conducted in sequence.

	1. Update Drivers Set Inactive = -5 Where ID = 1 '[executes with no
error]
	2. Select CLNG(Inactive) From Drivers Where ID = 1 '[result is -1]

It is intuitive to most good programmers, no doubt, that Access
force-converts non-zero integers to a Boolean value of -1, but I confess at
times the silent conversion confounds me, and I think it would be better for
Access to throw a runtime error upon query execution.

So I totally agree with you that as long as I have a caption or label saying
"Active" next to the option button that has value 0, in the option group
that is bound to the field named Inactive, then I can give the other option
button any non-zero integer value I care to, however the very first time
that control is set to NOT FALSE via reading information from the table, the
value will become -1, regardless what I might think I can cleverly test for
/ set via the interface. 

So I think it is better practice to make the option button with a caption or
label = "INACTIVE" have the option value of -1.

Does that make any sense?

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve Schapel
Sent: Tuesday, August 05, 2014 11:48 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Creating default false in yes/no field

Ah, that makes more sense, Bill!  :)

Actually, Access evaluates any non-zero integer as True.  So I think it
would work anyway with the option value of the two option buttons as 0 and
anything else you fancy.

Regards
Steve

-----Original Message-----
From: Bill Benson
Sent: Wednesday, August 6, 2014 2:15 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Creating default false in yes/no field

I just realize I had a typo (omission) which made me look pretty ignorant. 
What I meant to write to Steve was that I did not know one could make valid
use of NEGATIVE option button values. Of course I knew one could assign
values, but I thought they had to be 0-based. Heh Heh, dust off the old
Dunce cap, eh?



From: Bill Benson [mailto:bensonforums at gmail.com]
Sent: Saturday, August 02, 2014 4:21 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Creating default false in yes/no field



Wow Steve, I did not know I could give option buttons values.. This is a
useful trick you have given!

Very clever!

-Bill
On Aug 2, 2014 4:13 PM, "Steve Schapel" <steve at datamanagementsolutions.biz
<mailto:steve at datamanagementsolutions.biz> > wrote:
>
> Bill
>
> You could have saved yourself a bit of trouble here by simply binding 
> the option group to the Yes/No field, and setting the Option Value of 
> the option buttons to -1 and 0.
>
> No hidden control, no code.
>
> Regards
> Steve
>

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list