Link to home
Start Free TrialLog in
Avatar of Pigdogmonster
Pigdogmonster

asked on

Simple IF NOT Statement

I have this IF NOT Statement:-

<% if NOT varRequest ="All New loads" OR  varRequest ="All New NEW Loads" then%>

<DIV title="Manifest has arrived">M = Manifest has Arrived</div>
<DIV title="Booked out">B = Load Booked Out</DIV>
<DIV title="Arrival of Driver">A = Arrival of Driver</DIV>
<%end if%>

I have also added an OR in the statement, for some reason it does not pick up the second part of the OR statement.

Am I using the incorrect syntax?  
I have tried:-

<% if NOT varRequest ="All New loads" OR NOT  varRequest ="All New NEW Loads" then%>

and this does not work either.

please help
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rajmahesh
Rajmahesh

hi
if both the conditions are checking for not having that value u can use like

<% if varRequest <> "All New loads" OR varRequest <> "All New NEW Loads" then%>

this ll work
Avatar of Pigdogmonster

ASKER

thats it! thanks.

Do normal IF statements work without the brackets?  i.e

if varRequest ="All New loads" OR  varRequest ="All New NEW Loads" then

These seem to work wothout the brackets?
Rajmahesh,

No you cannot, that will actually make it happen every time, need an AND if you are negatively testing two exclusive conditions:

<% if varRequest <> "All New loads" AND varRequest <> "All New NEW Loads" then%>

Or

<% if NOT varRequest ="All New loads" AND NOT  varRequest ="All New NEW Loads" then%>

Tim.
im sorry timcottee
i dint see that
that should be as u said
that's a mistake
Rajmahesh's solution will always return true:

if varRequest <> "All New loads" OR varRequest <> "All New NEW Loads"

varRequest = "All New loads"  ->  if False Or True  ->  True
varRequest = "All New NEW Loads"  ->  if True Or False  ->  True

What you probably want is

if varRequest <> "All New loads" AND varRequest <> "All New NEW Loads"

Pigdogmonster, the brackets <> mean "is not equal to".  the condition can also be stated this way:

if Not varRequest = "All New loads" AND Not varRequest = "All New NEW Loads"

or even:

if Not (varRequest = "All New loads" OR varRequest = "All New NEW Loads")

the reason for the OR in the last version is that using the NOT outside the brackets changes the AND to an OR
oops... I don't know why I didn't see the two comments above mine... never mind me :|