Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Outgrew Iif And - what is alternative? Access 07

$
0
0
I needed a way to determine what the companies service charge on a customer invoice is based on 2 criteria.....this company has independent sales reps so they are charged a fee for the invoices they put through
If it is an invoice for a freight charge (shown in table as FRTINV = 1) - there is no order charge
If it is not an invoice for freight (shown in table as FRTINV =0 - then the charge is variable based on INVAMT
I have been running this expression in my invoices query which returned the correct results:
1. IIf([FRTINV]=1,0,
2. IIf([FRTINV]=0 And [INVAMT]<50,0,
3. IIf([FRTINV]=0 And [INVAMT]<201,2,
4. IIf([FRTINV]=0 And [INVAMT]<601,4,
5. IIf([FRTINV]=0 And [INVAMT]<1001,6,
6. IIf([FRTINV]=0 And [INVAMT]<2501,15,
7. IIf([FRTINV]=0 And [INVAMT]<5001,30,
8. IIf([FRTINV]=0 And [INVAMT]<10001,60,
9. IIf([FRTINV]=0 And [INVAMT]<25001,90,120)))))))))

the problem I have now is the table has changed whereas I have invoices in different currencies and the resulting order charges are different.
I am trying to limit queries in this database for efficiency

so for me to get accurate order charges now i have to add another criteria to each of these 9 lines where CURRENCY = "USD", then continue on with more Iif lines for each set of currencies(total of 3).
I am unable to get the 3 criteria to work for USD - I tried this:
IIf(([FRTINV]=0) And ([CURRENCY]=”USD”) And ([INVAMT]<50),0),
etc etc
It can only return 0 , or 120 so I know something in the structure is incorrect.

and if I get the structure correct, can I add 32 more Iif lines? It doesn't seem efficient

the hierarchy to this is:
1.) is it freight invoice? YES = no order charge enter 0.00, done
NO = it has a order charge, continue
2.) what is the currency? USD = US Order Charges
EUR = EUR Order Charges
RMB = RMB Order Charges
3.) what is the invoice amount?

If I create cases for the order charges how do I start?
First I want to yes the invoices that are not for freight
CASE FRT
[FRTINV] = 1
CASE ORDERCHARGE
[FRTINV] =0
Then another case for all ORDERCHARGE invoices?
do I start with the charge or with the invoice? such as:
CASE 0
"USD"<50 and "RMB"<300 and "EUR"<40
*this is saying that the order charge is 0 if the invoices are.......
CASE 1
"USD" <50 = 0
*this is saying my first case is a USD invoice under 50 is 0
which way will VBA want to read this?
from there - how do I pull the case into the query to get the result?

Appreciate any help or insight you can provide!

Viewing all articles
Browse latest Browse all 13329

Trending Articles