If Statement with And and Or

A

Ann

I wrote the following calculation on a form and it does work, however, I know
that it can be combined. I have been trying, but no matter how I combine
them I keep getting errors.

Here is what I have without combining the last two IIfs.

=IIf(([txtBannerType]="Standard" And [txtPaperType]="Large Format Bright
White (#24)"),[lngCount]*5,IIf(([txtBannerType]="Customized" And
[txtPaperType]="Large Format Bright White
(#24)"),([lngCount]*[lngFeet])*1,IIf(([txtBannerType]="Standard" And
[txtPaperType]="Standard White
Continuous"),[lngCount]*5,IIf(([txtBannerType]="Customized" And
[txtPaperType]="Standard White Continuous"),([lngCount]*[lngFeet])*1))))

I just need to say the [txtPaperType] can be Large Format... or Standard
White... but I'm a beginner and I can't get it right. Can anyone help me?
Thanks in advance.
 
K

KARL DEWEY

I just need to say the [txtPaperType] can be Large Format... or Standard
White...
Your IIF statements are testing for "Standard" and "Large Format Bright
White (#24)" and if true then display [lngCount]*5 which would be a number,
not a paper discription.

You also have syntax errors that are corrected below --
=IIf(([txtBannerType]="Standard" And [txtPaperType]="Large Format Bright
White (#24)", [lngCount]*5, IIf(([txtBannerType]="Customized" And
[txtPaperType]="Large Format Bright White (#24)", ([lngCount]*[lngFeet])*1,
IIf(([txtBannerType]="Standard" And [txtPaperType]="Standard White
Continuous"), [lngCount]*5, IIF([txtBannerType]="Customized" And
[txtPaperType]="Standard White Continuous", [lngCount]*[lngFeet]*1))))

Your last test has [lngCount]*[lngFeet]*1 for true results but no false
results is entered. False would be like this ... [lngCount]*[lngFeet]*1,
"Something is wrong here"))))
 
A

Ann

Your IIF statements are testing for "Standard" and "Large Format Bright
White (#24)" and if true then display [lngCount]*5 which would be a number,
not a paper discription.

Yes that is true...it's a number. Depending on the criteria for
txtPaperType and txtBannerType will depend on how much I charge for a banner.

I'm trying to combine them because the Standard for txtBannerType and Large
Format... or Standard White for txtPaper Type are the same fee, $5 per banner.

And the Customized for txtBannerType and Large Format...or Standard White
for txtPaperType is $1 per foot per banner so I don't need these to be
separate. Right now I have four if statements and I want to combine them
into two statements.


KARL DEWEY said:
I just need to say the [txtPaperType] can be Large Format... or Standard
White...
Your IIF statements are testing for "Standard" and "Large Format Bright
White (#24)" and if true then display [lngCount]*5 which would be a number,
not a paper discription.

You also have syntax errors that are corrected below --
=IIf(([txtBannerType]="Standard" And [txtPaperType]="Large Format Bright
White (#24)", [lngCount]*5, IIf(([txtBannerType]="Customized" And
[txtPaperType]="Large Format Bright White (#24)", ([lngCount]*[lngFeet])*1,
IIf(([txtBannerType]="Standard" And [txtPaperType]="Standard White
Continuous"), [lngCount]*5, IIF([txtBannerType]="Customized" And
[txtPaperType]="Standard White Continuous", [lngCount]*[lngFeet]*1))))

Your last test has [lngCount]*[lngFeet]*1 for true results but no false
results is entered. False would be like this ... [lngCount]*[lngFeet]*1,
"Something is wrong here"))))

--
Build a little, test a little.


Ann said:
I wrote the following calculation on a form and it does work, however, I know
that it can be combined. I have been trying, but no matter how I combine
them I keep getting errors.

Here is what I have without combining the last two IIfs.

=IIf(([txtBannerType]="Standard" And [txtPaperType]="Large Format Bright
White (#24)"),[lngCount]*5,IIf(([txtBannerType]="Customized" And
[txtPaperType]="Large Format Bright White
(#24)"),([lngCount]*[lngFeet])*1,IIf(([txtBannerType]="Standard" And
[txtPaperType]="Standard White
Continuous"),[lngCount]*5,IIf(([txtBannerType]="Customized" And
[txtPaperType]="Standard White Continuous"),([lngCount]*[lngFeet])*1))))

I just need to say the [txtPaperType] can be Large Format... or Standard
White... but I'm a beginner and I can't get it right. Can anyone help me?
Thanks in advance.
 
A

Ann

I also copied and pasted your code with the correct syntax and received the
following error: The expression you entered has the wrong number of
arguments.

KARL DEWEY said:
I just need to say the [txtPaperType] can be Large Format... or Standard
White...
Your IIF statements are testing for "Standard" and "Large Format Bright
White (#24)" and if true then display [lngCount]*5 which would be a number,
not a paper discription.

You also have syntax errors that are corrected below --
=IIf(([txtBannerType]="Standard" And [txtPaperType]="Large Format Bright
White (#24)", [lngCount]*5, IIf(([txtBannerType]="Customized" And
[txtPaperType]="Large Format Bright White (#24)", ([lngCount]*[lngFeet])*1,
IIf(([txtBannerType]="Standard" And [txtPaperType]="Standard White
Continuous"), [lngCount]*5, IIF([txtBannerType]="Customized" And
[txtPaperType]="Standard White Continuous", [lngCount]*[lngFeet]*1))))

Your last test has [lngCount]*[lngFeet]*1 for true results but no false
results is entered. False would be like this ... [lngCount]*[lngFeet]*1,
"Something is wrong here"))))

--
Build a little, test a little.


Ann said:
I wrote the following calculation on a form and it does work, however, I know
that it can be combined. I have been trying, but no matter how I combine
them I keep getting errors.

Here is what I have without combining the last two IIfs.

=IIf(([txtBannerType]="Standard" And [txtPaperType]="Large Format Bright
White (#24)"),[lngCount]*5,IIf(([txtBannerType]="Customized" And
[txtPaperType]="Large Format Bright White
(#24)"),([lngCount]*[lngFeet])*1,IIf(([txtBannerType]="Standard" And
[txtPaperType]="Standard White
Continuous"),[lngCount]*5,IIf(([txtBannerType]="Customized" And
[txtPaperType]="Standard White Continuous"),([lngCount]*[lngFeet])*1))))

I just need to say the [txtPaperType] can be Large Format... or Standard
White... but I'm a beginner and I can't get it right. Can anyone help me?
Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top