[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Negative Value in Boolean field

Branimir Petrovic

11/8/2008 1:10:00 PM

Hi

I have a field of type Boolean (lets name it X), in Access, but i need to
insert -1, not true or false to display a checkbox as unchecked, since the
app is developed in VBA, i could find out from the code that it get values
of 3 fields and field X must be -1 to display the checkbox as unchecked.

How do i insert -1 in a DataRow Object
row.X = -1

TIA
Barry



8 Answers

sloan

11/8/2008 2:34:00 PM

0


You need to use

=0 (false)
or
<>0 (true)

for your true/false checks.

Do not use =1 or =-1



"Barry" <someone@somewhere.com> wrote in message
news:uHSjDNaQJHA.588@TK2MSFTNGP06.phx.gbl...
> Hi
>
> I have a field of type Boolean (lets name it X), in Access, but i need to
> insert -1, not true or false to display a checkbox as unchecked, since the
> app is developed in VBA, i could find out from the code that it get values
> of 3 fields and field X must be -1 to display the checkbox as unchecked.
>
> How do i insert -1 in a DataRow Object
> row.X = -1
>
> TIA
> Barry
>
>
>


PvdG42

11/8/2008 3:04:00 PM

0


"Barry" <someone@somewhere.com> wrote in message
news:uHSjDNaQJHA.588@TK2MSFTNGP06.phx.gbl...
> Hi
>
> I have a field of type Boolean (lets name it X), in Access, but i need to
> insert -1, not true or false to display a checkbox as unchecked, since the
> app is developed in VBA, i could find out from the code that it get values
> of 3 fields and field X must be -1 to display the checkbox as unchecked.
>
> How do i insert -1 in a DataRow Object
> row.X = -1
>
> TIA
> Barry
>
Barry,
If your question is related to MS Access, as it appears to be, you'll have
much better response if you ask in an Access group.
There are several Access groups available, among which are:

microsoft.public.access

microsoft.public.access.modulesdaovba

Branimir Petrovic

11/9/2008 7:37:00 AM

0


Thanks for your reply. I need to insert the value in a Access Database but
using a application developed in C#, hence the posting on this forum. i have
also posted other questions in this regard here itself.


"PvdG42" <pvdg42@toadstool.edu> wrote in message
news:F6027611-DB65-4019-A519-5F658767283E@microsoft.com...
>
> "Barry" <someone@somewhere.com> wrote in message
> news:uHSjDNaQJHA.588@TK2MSFTNGP06.phx.gbl...
>> Hi
>>
>> I have a field of type Boolean (lets name it X), in Access, but i need to
>> insert -1, not true or false to display a checkbox as unchecked, since
>> the app is developed in VBA, i could find out from the code that it get
>> values of 3 fields and field X must be -1 to display the checkbox as
>> unchecked.
>>
>> How do i insert -1 in a DataRow Object
>> row.X = -1
>>
>> TIA
>> Barry
>>
> Barry,
> If your question is related to MS Access, as it appears to be, you'll have
> much better response if you ask in an Access group.
> There are several Access groups available, among which are:
>
> microsoft.public.access
>
> microsoft.public.access.modulesdaovba
>


Branimir Petrovic

11/9/2008 7:39:00 AM

0



Thanks for your reply, unfortunately i MUST insert -1 in the field, i have
found the answer

row.X = Convert.ToBoolean(-1);




"sloan" <sloan@ipass.net> wrote in message
news:eHQY6MbQJHA.4388@TK2MSFTNGP06.phx.gbl...
>
> You need to use
>
> =0 (false)
> or
> <>0 (true)
>
> for your true/false checks.
>
> Do not use =1 or =-1
>
>
>
> "Barry" <someone@somewhere.com> wrote in message
> news:uHSjDNaQJHA.588@TK2MSFTNGP06.phx.gbl...
>> Hi
>>
>> I have a field of type Boolean (lets name it X), in Access, but i need to
>> insert -1, not true or false to display a checkbox as unchecked, since
>> the app is developed in VBA, i could find out from the code that it get
>> values of 3 fields and field X must be -1 to display the checkbox as
>> unchecked.
>>
>> How do i insert -1 in a DataRow Object
>> row.X = -1
>>
>> TIA
>> Barry
>>
>>
>>
>
>


jacerhea

11/9/2008 3:38:00 PM

0

> Thanks for your reply, unfortunately i MUST insert -1 in the field, i have
> found the answer
>
> row.X = Convert.ToBoolean(-1);

I'm glad that worked for you, but Convert.ToBoolean is going to return
a Boolean data type with a value of true or false, not a signed int.

-1 is NOT being assigned to the field row.x. Its being cast to a data
type of Boolean. http://msdn.microsoft.com/en-us/library/h0b...

Branimir Petrovic

11/10/2008 8:14:00 AM

0


what you say could be right, but for me what matters is that it works and
get the job done, some of the work is time-bound and i cannot afford to
search for what is theortically correct


"jacerhea" <jace.rhea@gmail.com> wrote in message
news:92300f72-ed1e-4199-b460-eee2f0a5fd38@r15g2000prh.googlegroups.com...
>> Thanks for your reply, unfortunately i MUST insert -1 in the field, i
>> have
>> found the answer
>>
>> row.X = Convert.ToBoolean(-1);
>
> I'm glad that worked for you, but Convert.ToBoolean is going to return
> a Boolean data type with a value of true or false, not a signed int.
>
> -1 is NOT being assigned to the field row.x. Its being cast to a data
> type of Boolean. http://msdn.microsoft.com/en-us/library/h0b...


PvdG42

11/10/2008 1:04:00 PM

0


"Barry" <someone@somewhere.com> wrote in message
news:uepwB5jQJHA.4060@TK2MSFTNGP02.phx.gbl...
>
>
> Thanks for your reply, unfortunately i MUST insert -1 in the field, i have
> found the answer
>
> row.X = Convert.ToBoolean(-1);
>
I hope you don't ever have to check that field for a value of -1, because it
won't be there:

bool t;
t = Convert.ToBoolean(-1);
int i = Convert.ToInt32(t);
Console.WriteLine("T = {0}, and I = {1}", t.ToString(),
i.ToString());

yields: T = true and I = 1 (not -1)


Branimir Petrovic

11/10/2008 1:17:00 PM

0


What you have written maybe right.

But you could try inserting in a Access database table which has type
Yes/No a value of -1 and it shows up in the table

Try inserting the value using C# code not directly in the Table through
Access


"PvdG42" <pvdg42@toadstool.edu> wrote in message
news:671992AE-7B19-4AAF-BEBE-5D05BA3D8514@microsoft.com...
>
> "Barry" <someone@somewhere.com> wrote in message
> news:uepwB5jQJHA.4060@TK2MSFTNGP02.phx.gbl...
>>
>>
>> Thanks for your reply, unfortunately i MUST insert -1 in the field, i
>> have found the answer
>>
>> row.X = Convert.ToBoolean(-1);
>>
> I hope you don't ever have to check that field for a value of -1, because
> it won't be there:
>
> bool t;
> t = Convert.ToBoolean(-1);
> int i = Convert.ToInt32(t);
> Console.WriteLine("T = {0}, and I = {1}", t.ToString(),
> i.ToString());
>
> yields: T = true and I = 1 (not -1)
>
>