Negative Value in Boolean field

  • Thread starter Thread starter Barry
  • Start date Start date
B

Barry

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
 
You need to use

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

for your true/false checks.

Do not use =1 or =-1
 
Barry said:
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
 
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.
 
Thanks for your reply, unfortunately i MUST insert -1 in the field, i have
found the answer

row.X = Convert.ToBoolean(-1);
 
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
 
Barry said:
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)
 
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
 
Back
Top