using OR in form text boxes

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

Guest

Please could anyone let me know whether it is possible to use an 'OR'
statement in the formula for text boxes, and if so what the correct syntax
for this would be?

I know an alternative would be to use nested iif statements but for what I
need this seems rather convoluted and an OR statement would be preferable if
it can be used, though I am having trouble implementing such an expression.

Many thanks,
Sarah
 
Unless you give us the statement you are trying to use, it would be rather
hard for us to send you a response.

Tell us what you want to accomplish in English, and we'll try to turn it
into Access-ese.

Rick B
 
=IIf([TestID]=1 Or [TestID]=2,"1 or 2","Not 1 or 2")

A common mistake is to try to do something like ...

=IIf([TestID]=1 Or 2,"1 or 2","Not 1 or 2")

Rather than comparing the value of TestID to 1 and also comparing the value
of TestID to 2, this expression gets evaluated something like this ...

If (TestID = 1) Or (2 <> False)

Of course, 2 is never equal to false, so the second example above would
return "1 or 2" no matter what the value of TestID happened to be.
 
Thanks Brendan, that's great.


Brendan Reynolds said:
=IIf([TestID]=1 Or [TestID]=2,"1 or 2","Not 1 or 2")

A common mistake is to try to do something like ...

=IIf([TestID]=1 Or 2,"1 or 2","Not 1 or 2")

Rather than comparing the value of TestID to 1 and also comparing the value
of TestID to 2, this expression gets evaluated something like this ...

If (TestID = 1) Or (2 <> False)

Of course, 2 is never equal to false, so the second example above would
return "1 or 2" no matter what the value of TestID happened to be.

--
Brendan Reynolds (MVP)


access user said:
Please could anyone let me know whether it is possible to use an 'OR'
statement in the formula for text boxes, and if so what the correct syntax
for this would be?

I know an alternative would be to use nested iif statements but for what I
need this seems rather convoluted and an OR statement would be preferable
if
it can be used, though I am having trouble implementing such an
expression.

Many thanks,
Sarah
 
Back
Top