Select IIF

S

Scotty

I'm having trouble with my select iif statement:

Select: IIf ([EscPmtAmt]>0 And [DisbCd]<1),"LIST",0)

I get message:

The expression you entered has a function containing the wrong number of
arguments
 
B

BruceM

There's an extra parentheses after [DisbCd]<1

I don't think it's a good idea to use "Select" as an alias query field, if
that's what you're doing. "Select" is very important in SQL (the language
underlying a query), and there could be confusion. I don't know this for
sure, but I suspect it could be a problem.
 
J

Jerry Whittle

Try this. Hopefully all the cold medicine hasn't fogged my brain too much!

IIf ([EscPmtAmt]<=0, 0, IIf([DisbCd]<1,"LIST",0))
 
S

Scotty

Thanks, didn't realize I could just use IIF without select.

BruceM said:
There's an extra parentheses after [DisbCd]<1

I don't think it's a good idea to use "Select" as an alias query field, if
that's what you're doing. "Select" is very important in SQL (the language
underlying a query), and there could be confusion. I don't know this for
sure, but I suspect it could be a problem.


Scotty said:
I'm having trouble with my select iif statement:

Select: IIf ([EscPmtAmt]>0 And [DisbCd]<1),"LIST",0)

I get message:

The expression you entered has a function containing the wrong number of
arguments
 
B

BruceM

I'm just suggesting that you use a word other than "Select". You can call
it ListOrNot, or anything that suits you. You can use a space in the name
(which is known as an alias), but again it is simpler if you limit names to
alphanumeric characters and the underscore character.

If you open the query in design view and click View > SQL you would see
something like:
SELECT IIf ([EscPmtAmt]>0 And [DisbCd]<1),"LIST",0) As [Select]
FROM YourTable

Even if "SELECT (something) as [Select]" is allowed, you may do best to
avoid it when you work directly with the SQL language. It could get
confusing.


Scotty said:
Thanks, didn't realize I could just use IIF without select.

BruceM said:
There's an extra parentheses after [DisbCd]<1

I don't think it's a good idea to use "Select" as an alias query field,
if
that's what you're doing. "Select" is very important in SQL (the
language
underlying a query), and there could be confusion. I don't know this for
sure, but I suspect it could be a problem.


Scotty said:
I'm having trouble with my select iif statement:

Select: IIf ([EscPmtAmt]>0 And [DisbCd]<1),"LIST",0)

I get message:

The expression you entered has a function containing the wrong number
of
arguments
 
P

Pieter Wijnen

AKA hungarian notation

Pieter

BruceM said:
I'm just suggesting that you use a word other than "Select". You can call
it ListOrNot, or anything that suits you. You can use a space in the name
(which is known as an alias), but again it is simpler if you limit names
to alphanumeric characters and the underscore character.

If you open the query in design view and click View > SQL you would see
something like:
SELECT IIf ([EscPmtAmt]>0 And [DisbCd]<1),"LIST",0) As [Select]
FROM YourTable

Even if "SELECT (something) as [Select]" is allowed, you may do best to
avoid it when you work directly with the SQL language. It could get
confusing.


Scotty said:
Thanks, didn't realize I could just use IIF without select.

BruceM said:
There's an extra parentheses after [DisbCd]<1

I don't think it's a good idea to use "Select" as an alias query field,
if
that's what you're doing. "Select" is very important in SQL (the
language
underlying a query), and there could be confusion. I don't know this
for
sure, but I suspect it could be a problem.


I'm having trouble with my select iif statement:

Select: IIf ([EscPmtAmt]>0 And [DisbCd]<1),"LIST",0)

I get message:

The expression you entered has a function containing the wrong number
of
arguments
 
Top