If then....

1. Member
Join Date
Dec 1969
Posts
83

If then....

Can anyone tell me how to do an IF statement with two criteria where one of those cannot be one of two values?<BR><BR>For example:<BR>If (devl = "All" and district &#060;&#062; 1 or dist &#060;&#062; 3) or assoc = "All" then <BR>SQL="INSERT ......<BR>Else<BR>End If<BR><BR>I only want it to insert if assoc is "all" OR devl is "all" and district is not equal to 1 or 3. <BR><BR>Thanks!

2. Senior Member
Join Date
Dec 1969
Posts
2,437

RE: If then....

If (devl = "All" and district &#060;&#062; 1 and district &#060;&#062; 3) or assoc = "All" then

3. Senior Member
Join Date
Dec 1969
Posts
1,570

try this...

If (devl = "All" OR assoc = "All") AND district &#060;&#062; 1 AND district &#060;&#062; 3 then <BR>SQL="INSERT ...... <BR>Else <BR>End If

4. Senior Member
Join Date
Dec 1969
Posts
2,334

RE: If then....

Can&#039;t say why that won&#039;t work...It should with the right parenthesis...<BR><BR>If (devl = "All" and (district &#060;&#062; 1 or dist &#060;&#062; 3)) or assoc = "All" then <BR><BR>OR you may try this...<BR><BR>If devl = "ALL" Then<BR> If (district &#060;&#062; 1 or dis &#060;&#062; 3) Then<BR> CODE<BR> End If<BR>Else<BR> If devl = "All" Then<BR> CODE<BR> End If<BR>End IF

5. Senior Member
Join Date
Dec 1969
Posts
96,118

Listen to Lars...

...the other two answers are wrong.<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
1,570

RE: Listen to Lars...

why is mine wrong anyhow? I didn&#039;t think to much about the question, but to me it looks like it would work?

7. God
Senior Member
Join Date
Dec 1969
Posts
18,177

RE: Listen to Lars...

If "All" is checked, he doesn&#039;t care about the district.<BR><BR>Otherwise, he doesn&#039;t want to be 1 or 3.

8. Member
Join Date
Dec 1969
Posts
83

RE: If then....

don&#039;t know what I was doing wrong. Stupid parantheses I guess. Thanks!

9. Member
Join Date
Dec 1969
Posts
83

RE: Listen to Lars...

that&#039;s true, but it does matter if the devl is "all"

10. Senior Member
Join Date
Dec 1969
Posts
1,570

RE: Listen to Lars...

I must have misunderstood the question I guess. I must already be thinking about how much football I am going to watch and partying I am going to do this weekend!!<BR><BR>have a good one...

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•