A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

If Statement with And and Or



 
 
Thread Tools Display Modes
  #1  
Old November 17th, 2009, 04:27 PM posted to microsoft.public.access.forms
ann
external usenet poster
 
Posts: 462
Default If Statement with And and Or

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.
  #2  
Old November 17th, 2009, 04:41 PM posted to microsoft.public.access.forms
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default If Statement with And and Or

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" wrote:

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.

  #3  
Old November 18th, 2009, 12:18 PM posted to microsoft.public.access.forms
ann
external usenet poster
 
Posts: 462
Default If Statement with And and Or

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" wrote:

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" wrote:

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.

  #4  
Old November 18th, 2009, 12:25 PM posted to microsoft.public.access.forms
ann
external usenet poster
 
Posts: 462
Default If Statement with And and Or

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" wrote:

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" wrote:

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.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:08 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.