L
LSH
Is it possible to store formulas in a table based on site
IDs and then pull the formulas into a query?
For example if I have a table called tblTaxes with fields
lngSiteID - long
dblFedTax - double
dblSTTax - double
dblCountyTax - double
dblLocalTax - double
dlbMiscTax - double
dblSalesPer - double
txtFormula - text
another table
tblSales
lngSiteID - long
dblTotSales - double
There are different formulas to calculate the total tax. A
formula could be ([dblTotSales]+ [dblFedTax]) *
[dblSalesPer]) + [dblSTTax] or it could be (([dblTotSales]
+ [dblFedTax] + [dblSTTax])* [dblSalesPer]). This is a
simplified example and there are many different formulas.
I could do this through code or a nested iif statement,
but was wanting to be able to store the formulas in a
table so that a user could modify them or add as needed. I
tried storing the formula in the [txtformula] field
as "([dblTotSales]+ [dblFedTax]) * [dblSalesPer]) +
[dblSTTax]" (no actual quotes in the field)
Playing around with it, if I pull the formula out of the
table in a query by joining the above tables by lngSiteID,
it just displays as a text string. Is there anyway to tell
Access this is a formula? I tried the Eval function, but
could not get it to work.
Any suggestions on how to make this work or am I way off
base here ... is there a better way to do this.
thanks
Laura
IDs and then pull the formulas into a query?
For example if I have a table called tblTaxes with fields
lngSiteID - long
dblFedTax - double
dblSTTax - double
dblCountyTax - double
dblLocalTax - double
dlbMiscTax - double
dblSalesPer - double
txtFormula - text
another table
tblSales
lngSiteID - long
dblTotSales - double
There are different formulas to calculate the total tax. A
formula could be ([dblTotSales]+ [dblFedTax]) *
[dblSalesPer]) + [dblSTTax] or it could be (([dblTotSales]
+ [dblFedTax] + [dblSTTax])* [dblSalesPer]). This is a
simplified example and there are many different formulas.
I could do this through code or a nested iif statement,
but was wanting to be able to store the formulas in a
table so that a user could modify them or add as needed. I
tried storing the formula in the [txtformula] field
as "([dblTotSales]+ [dblFedTax]) * [dblSalesPer]) +
[dblSTTax]" (no actual quotes in the field)
Playing around with it, if I pull the formula out of the
table in a query by joining the above tables by lngSiteID,
it just displays as a text string. Is there anyway to tell
Access this is a formula? I tried the Eval function, but
could not get it to work.
Any suggestions on how to make this work or am I way off
base here ... is there a better way to do this.
thanks
Laura