×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Or followed by And function question

Or followed by And function question

Or followed by And function question

(OP)
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: Or followed by And function question

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

ElseIf (FL02 = True Or FL04 = True Or FL05 = True) _
    And dap = True And disposable = True _
    And warehouse = True And norepack = True Then
...
 
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.

RE: Or followed by And function question

You may check the precedence of operators here.
As you have boolean variables, shorter but less descriptive version:
ElseIf (FL02 Or FL04 Or FL05) And dap And disposable And warehouse And norepack Then

combo

RE: Or followed by And function question

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

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.

RE: Or followed by And function question

(OP)
Hi Andy,

1 of the Or statements needs to be true.

All of the And statements needs to be true.

Thanks,

Mike

RE: Or followed by And function question

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.

RE: Or followed by And function question

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close