Can anyone tell me what is wrong with this IIf statement

G

Guest

I cannot run a query with this iff statement.

All it is meant to do is look at the business and cost centre, return the
integer of someone's age or return their age within the upper and lower
limits of redundancy age.

IIf([oribus]="MainBusiness" And ([oldcostcen]<>"North" Or
[pldcostcen]<>"West"),Int([pnageactual]),Min(Max([Z Redundancy]!Age) Or
Max([pnageactual] Or Min([Z Redundancy]!Age))))

Does anyone have any suggestions as to why this query does not work.

Thanks
Nuno
 
G

Guest

I see several things. You did not say what error messages you are getting.
You may be getting this -- "You tried to execute a query that does not
include the specified expression as part of an aggregate function or
grouping." If so, then it needs to be part of a Totals query, use a sub
query, or a separate Totals query joined in this one.
Min(Max([Z Redundancy]!Age) Or Max([pnageactual] Or Min([Z
Redundancy]!Age))))
You can not have minimum of three different fields OR'd like this.

Post the complete query SQL and the error messages.
--
KARL DEWEY
Build a little - Test a little


Nuno Bento said:
I cannot run a query with this iff statement.

All it is meant to do is look at the business and cost centre, return the
integer of someone's age or return their age within the upper and lower
limits of redundancy age.

IIf([oribus]="MainBusiness" And ([oldcostcen]<>"North" Or
[pldcostcen]<>"West"),Int([pnageactual]),Min(Max([Z Redundancy]!Age) Or
Max([pnageactual] Or Min([Z Redundancy]!Age))))

Does anyone have any suggestions as to why this query does not work.

Thanks
Nuno
 
G

Guest

Hi Karl,

Thanks for your reply. Not sure I know how to apply your solution, but I'll
look into it.

Thanks
Nuno

KARL DEWEY said:
I see several things. You did not say what error messages you are getting.
You may be getting this -- "You tried to execute a query that does not
include the specified expression as part of an aggregate function or
grouping." If so, then it needs to be part of a Totals query, use a sub
query, or a separate Totals query joined in this one.
Min(Max([Z Redundancy]!Age) Or Max([pnageactual] Or Min([Z
Redundancy]!Age))))
You can not have minimum of three different fields OR'd like this.

Post the complete query SQL and the error messages.
--
KARL DEWEY
Build a little - Test a little


Nuno Bento said:
I cannot run a query with this iff statement.

All it is meant to do is look at the business and cost centre, return the
integer of someone's age or return their age within the upper and lower
limits of redundancy age.

IIf([oribus]="MainBusiness" And ([oldcostcen]<>"North" Or
[pldcostcen]<>"West"),Int([pnageactual]),Min(Max([Z Redundancy]!Age) Or
Max([pnageactual] Or Min([Z Redundancy]!Age))))

Does anyone have any suggestions as to why this query does not work.

Thanks
Nuno
 
G

Guest

You did not post your complete SQL statement as I asked.
--
KARL DEWEY
Build a little - Test a little


Nuno Bento said:
Hi Karl,

Thanks for your reply. Not sure I know how to apply your solution, but I'll
look into it.

Thanks
Nuno

KARL DEWEY said:
I see several things. You did not say what error messages you are getting.
You may be getting this -- "You tried to execute a query that does not
include the specified expression as part of an aggregate function or
grouping." If so, then it needs to be part of a Totals query, use a sub
query, or a separate Totals query joined in this one.
Min(Max([Z Redundancy]!Age) Or Max([pnageactual] Or Min([Z
Redundancy]!Age))))
You can not have minimum of three different fields OR'd like this.

Post the complete query SQL and the error messages.
--
KARL DEWEY
Build a little - Test a little


Nuno Bento said:
I cannot run a query with this iff statement.

All it is meant to do is look at the business and cost centre, return the
integer of someone's age or return their age within the upper and lower
limits of redundancy age.

IIf([oribus]="MainBusiness" And ([oldcostcen]<>"North" Or
[pldcostcen]<>"West"),Int([pnageactual]),Min(Max([Z Redundancy]!Age) Or
Max([pnageactual] Or Min([Z Redundancy]!Age))))

Does anyone have any suggestions as to why this query does not work.

Thanks
Nuno
 

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