Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Or followed by And function question 1

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
520
US
Hi,

I think I am not using the correct formatting in my if then statement. I'd like to make an Or criteria followed by an And criteria. I am sure that I am doing something wrong.

Conditions:

FL02, FL04, or FL05 = True

dap, disposable, warehouse, and norepack = True

Code:
ElseIf FL02 = True Or FL04 = True Or FL05 = True And dap = True And disposable = True And warehouse = True And norepack = True Then

        Slide271.forecast.Value = forecast
        Slide271.min.Value = batchmin
        Slide271.frozen_period.Value = frozen
        Slide271.dev_freq.Value = dev_freq
        'Slide271.hu.Value = hu

        ActivePresentation.SlideShowWindow.View.GotoSlide (10)

Where did I goof?

Thanks,

Mike
 
Re-write your IF statement using ( and ) around your logic for OR and AND, something like:

[pre]
ElseIf (FL02 = True Or FL04 = True Or FL05 = True) _
And dap = True And disposable = True _
And warehouse = True And norepack = True Then
...
[/pre]
At least one of these needs to be True: FL02, FL04, FL05
and all other pieces need to be True (...right?)


---- Andy

There is a great need for a sarcasm font.
 
You may check the precedence of operators here.
As you have boolean variables, shorter but less descriptive version:
[tt]ElseIf (FL02 Or FL04 Or FL05) And dap And disposable And warehouse And norepack Then[/tt]

combo
 
shorter but less descriptive" - not if you use some standards in naming your variables and give them some meaning.
For example, instead of: [tt]disposable[/tt], I would use [tt]blnIsDisposable[/tt] :)

Using word "IS' in the name of Booleans makes them easy to read and understand. Just don't use negatives like blnIsNotFound


---- Andy

There is a great need for a sarcasm font.
 
Hi Andy,

1 of the Or statements needs to be true.

All of the And statements needs to be true.

Thanks,

Mike
 
OK..... So, did you try my suggestion of using the parentheses around your logic?
If so, did it work?


---- Andy

There is a great need for a sarcasm font.
 
Hi Andy,

Yes it did work. I am still working on the different configurations and will let you know if I have any additional issues.

Thanks for the help,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top