How can I use a text string as a query parameter?

G

googlegooble

I am trying to build a query in which I need to create a variable parameter
based on a text string...

I have the Following Feilds:
UnitCount - Sum of units shipped
CaseCount - Sum of Cases shipped
FeeRate - the rate for a fee based on either UnitCount or CaseCount
FeeFactor - the feild that determains if the total Fee is based on UnitCount
of CaseCount

I want to create another feild that is equal to FeeRate x [NewParameter]*
* the new parameter is variable and would be equal to the following text
string:
="SumOf" & [FeeFactor]
If FeeFactor is equal to UnitCount then the formula would be FeeRate x
SumofFeeFactor

I tried: ["sumof" & [FeeFactor]] but it will not recognize this text string
as a parameter...

HELP!!!
 
M

Michel Walsh

A parameter will always be seen as data, not as structure (table, field,
....) neither as operator (+, -, SUM, ... ) . On the other hand, you can use
a switch, like:

SELECT ...,
SWITCH( param = "field1", field1, param="field2", field2,
param="field3", field3, ... ) AS whichField,
...
FROM ...



Vanderghast, Access MVP
 
G

Golfinray

Try:
Fee Rate:IIF([fee rate]=[unit count],[fee rate]*[sum of fee factor],[fee
rate]*[new parameter])
You may have to play with it a little to get exactly what you want, but you
need an IIF command.
 

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