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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using "AND" in an IIF function statement



 
 
Thread Tools Display Modes
  #1  
Old February 16th, 2007, 08:06 PM posted to microsoft.public.access.queries
AMFLMSC
external usenet poster
 
Posts: 2
Default Using "AND" in an IIF function statement

This is what I am trying to do:

I have two conditions that I want the if statement to look at.
If my CF_Premium is greater than 0 and my FLS_Premium is less than 0, add the
two values.

This is what I tried first and I get an error message:
Premium_Variance:IIF(and([CF_Premium]0,[FLS_Premium]0),[CF_Premium]+
[FLS_Premium],IIF(and([CF_Premium]0,[FLS_Premium]0),[CF_Premium]+
[FLS_Premium],0))

Then I tried this:

Premium_Variance:IIF([CF_Premium]0 and [FLS_Premium]0,[CF_Premium]+
[FLS_Premium],IIF([CF_Premium]0 and [FLS_Premium]0,[CF_Premium]+
[FLS_Premium],0))

  #2  
Old February 16th, 2007, 08:31 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Using "AND" in an IIF function statement

If my CF_Premium is greater than 0 and my FLS_Premium is less than 0, add
the two values.

IIF([CF_Premium]0 and [FLS_Premium]0,[CF_Premium]+[FLS_Premium],0)


"AMFLMSC" wrote:

This is what I am trying to do:

I have two conditions that I want the if statement to look at.
If my CF_Premium is greater than 0 and my FLS_Premium is less than 0, add the
two values.

This is what I tried first and I get an error message:
Premium_Variance:IIF(and([CF_Premium]0,[FLS_Premium]0),[CF_Premium]+
[FLS_Premium],IIF(and([CF_Premium]0,[FLS_Premium]0),[CF_Premium]+
[FLS_Premium],0))

Then I tried this:

Premium_Variance:IIF([CF_Premium]0 and [FLS_Premium]0,[CF_Premium]+
[FLS_Premium],IIF([CF_Premium]0 and [FLS_Premium]0,[CF_Premium]+
[FLS_Premium],0))


  #3  
Old February 16th, 2007, 08:59 PM posted to microsoft.public.access.queries
AMFLMSC
external usenet poster
 
Posts: 2
Default Using "AND" in an IIF function statement

Thanks!

  #4  
Old February 17th, 2007, 08:25 PM posted to microsoft.public.access.queries
Josh D
external usenet poster
 
Posts: 1
Default Using "AND" in an IIF function statement

Your first solution is an Ecel notation for AND -- and(varA,VarB,..VarN) and
does not work in VB. However, your second solution is correct only it adds
the 2 numbers together regardless if:
CF_Premium 0 AND FLS_Premium 0 *** OR ***
CF_Premium 0 AND FLS_Premium 0

Josh D

"AMFLMSC" wrote:

This is what I am trying to do:

I have two conditions that I want the if statement to look at.
If my CF_Premium is greater than 0 and my FLS_Premium is less than 0, add the
two values.

This is what I tried first and I get an error message:
Premium_Variance:IIF(and([CF_Premium]0,[FLS_Premium]0),[CF_Premium]+
[FLS_Premium],IIF(and([CF_Premium]0,[FLS_Premium]0),[CF_Premium]+
[FLS_Premium],0))

Then I tried this:

Premium_Variance:IIF([CF_Premium]0 and [FLS_Premium]0,[CF_Premium]+
[FLS_Premium],IIF([CF_Premium]0 and [FLS_Premium]0,[CF_Premium]+
[FLS_Premium],0))


 




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 08:43 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.