[AccessD] Creating default false in yes/no field

Bill Benson bensonforums at gmail.com
Wed Aug 6 04:31:37 CDT 2014


>> I shouldn't have idly thrown an idea in

I am glad you did, it caused me to learn something for myself.

Long Live AccessD!
 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve Schapel
Sent: Wednesday, August 06, 2014 4:49 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Creating default false in yes/no field

Thanks a lot for checking it, Bill.  And I agree entirely.  I apologise, I
shouldn't have idly thrown an idea in, which in practice I would never
actually do anyway, without thinking it through.

Regards
Steve

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

I have, in fact, just proved that setting to anything other than -1 DOES NOT
WORK. I opened the form on a record where that value was TRUE, and the
option button had a value of 5 in my test, and neither option button was
filled. When I changed the option control to have a value of -1 in design
view, then reloaded the form, that control was filled in.

See Steve, it does not pay to try to be too clever.

;-)

-----Original Message-----
From: Bill Benson [mailto:bensonforums at gmail.com]
Sent: Wednesday, August 06, 2014 12:31 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Creating default false in yes/no field

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


--
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