Solved

Simple IF NOT Statement

Posted on 2004-04-06
7
243 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:Pigdogmonster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 20 total points
ID: 10765953
Hi Pigdogmonster,

I assume you want:

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

Which will display your stuff if neither condition is true.

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 1

Expert Comment

by:Rajmahesh
ID: 10765987
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
0
 

Author Comment

by:Pigdogmonster
ID: 10766035
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?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 43

Expert Comment

by:TimCottee
ID: 10766041
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.
0
 
LVL 1

Expert Comment

by:Rajmahesh
ID: 10766163
im sorry timcottee
i dint see that
that should be as u said
that's a mistake
0
 
LVL 7

Expert Comment

by:brgivens
ID: 10767541
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
0
 
LVL 7

Expert Comment

by:brgivens
ID: 10767564
oops... I don't know why I didn't see the two comments above mine... never mind me :|
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question