Yes/No Check Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have checkbox named "Released"
Here is what I am doing
LocationStatus:
IIf([Released?]="yes","Delivered",IIf(Not
IsNull([Location]),"Warehouse/Yard","Intransit"))

This expression work correctly when the datatype is changed from a checkbox
to a text box and "yes" is typed in the textbox but is gives an error when
when it is a yes/no datatype and when its is checked. I think the problem is
the "yes" in the expression for the yes/no datatype I tried "1", I tried "-1"
and others. Please help
 
Levans said:
I have checkbox named "Released"
Here is what I am doing
LocationStatus:
IIf([Released?]="yes","Delivered",IIf(Not
IsNull([Location]),"Warehouse/Yard","Intransit"))

This expression work correctly when the datatype is changed from a
checkbox to a text box and "yes" is typed in the textbox but is gives
an error when when it is a yes/no datatype and when its is checked.
I think the problem is the "yes" in the expression for the yes/no
datatype I tried "1", I tried "-1" and others. Please help

Yes/No fields can be formatted to display the words "Yes" and "No", but that
does not make them "equal" to that display value. Access is pretty
forgiving of this, but you don't want quotes around the value if testing for
True/False or Yes/No.

I prefer to test for 0 (false) or not equal to zero (true) and do not use
quotes.

IIf([Released?]<>0,"Delivered",IIf(Not
IsNull([Location]),"Warehouse/Yard","Intransit"))

You "could" test for zero and/or negative one, but other systems like SQL
Server store a positive one for True whereas Access/Jet uses negative one
for True. Zero being equivelant to False is the same in Access/Jet, VBA
code, and SQL Server so always testing for zero or non-zero will not break
if you ever move your data to SQL Server.
 
I have checkbox named "Released"
Here is what I am doing
LocationStatus:
IIf([Released?]="yes","Delivered",IIf(Not
IsNull([Location]),"Warehouse/Yard","Intransit"))

This expression work correctly when the datatype is changed from a checkbox
to a text box and "yes" is typed in the textbox but is gives an error when
when it is a yes/no datatype and when its is checked. I think the problem is
the "yes" in the expression for the yes/no datatype I tried "1", I tried "-1"
and others. Please help

Is the Field named [Released] or [Released?] ?

A check box is a Boolean datatype, i.e. 0 or -1 or Yes or No or True
or False, etc., a number not Text "-1","Yes", "True" etc.

LocationStatus: IIf([Released]=-1,"Delivered",IIf(Not
IsNull([Location]),"Warehouse/Yard","Intransit"))
 
Hey Thanks very much it works.

One more question. I would like to create a query to select only the
"released?" goods, therefore all the fields that are checked on the yes/no
box.
And another query to select the "released?" goods that arnt check

What must I put in the crieteria column of the query. both queries I guess
its not yes and no or true and false or -1 and 0 ????

thanks

Rick Brandt said:
Levans said:
I have checkbox named "Released"
Here is what I am doing
LocationStatus:
IIf([Released?]="yes","Delivered",IIf(Not
IsNull([Location]),"Warehouse/Yard","Intransit"))

This expression work correctly when the datatype is changed from a
checkbox to a text box and "yes" is typed in the textbox but is gives
an error when when it is a yes/no datatype and when its is checked.
I think the problem is the "yes" in the expression for the yes/no
datatype I tried "1", I tried "-1" and others. Please help

Yes/No fields can be formatted to display the words "Yes" and "No", but that
does not make them "equal" to that display value. Access is pretty
forgiving of this, but you don't want quotes around the value if testing for
True/False or Yes/No.

I prefer to test for 0 (false) or not equal to zero (true) and do not use
quotes.

IIf([Released?]<>0,"Delivered",IIf(Not
IsNull([Location]),"Warehouse/Yard","Intransit"))

You "could" test for zero and/or negative one, but other systems like SQL
Server store a positive one for True whereas Access/Jet uses negative one
for True. Zero being equivelant to False is the same in Access/Jet, VBA
code, and SQL Server so always testing for zero or non-zero will not break
if you ever move your data to SQL Server.
 
Levans said:
Hey Thanks very much it works.

One more question. I would like to create a query to select only the
"released?" goods, therefore all the fields that are checked on the
yes/no box.
And another query to select the "released?" goods that arnt check

What must I put in the crieteria column of the query. both queries I
guess its not yes and no or true and false or -1 and 0 ????

For all the checked ones use a criteria of...

<> 0

For all of the unchecked ones use...

0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top