[AccessD] Need help with Eval() function

Mcgillivray, Donald [ITS] donald.a.Mcgillivray at mail.sprint.com
Tue Sep 9 11:34:18 CDT 2003


Hello, All

I need to calculate the cost of material for a series of products, each
of which has a number of different material components.  The cost of
each material component is calculated differently depending on what it
is.  For example, outside envelope cost is a function of the number of
mail pieces multiplied by the unit cost of the envelope; form cost is a
function of the number of pages multiplied by the unit cost of a single
form; toner cost is a function of the number of print feet multiplied by
the cost of toner per print foot; and so on.

I have constructed a query that delivers a row for each material type
used in each product.  Simplified, it looks something like this:

ProdID	Pieces	Pages		Printfeet	MatlTyp	UnitCost
CalcFormula
========================================================================
====================================
1		200		500		480		Envelope
.0135		tblVolume.Pieces * tblMaterial.UnitCost
1		200		500		480		Form
.0015		tblVolume.Pages * tblMaterial.UnitCost
1		200		500		480		Toner
.000025	tblVolume.Printfeet * tblMaterial.UnitCost
2		5000		20000		18000		Envelope
.0142		tblVolume.Pieces * tblMaterial.UnitCost
2		5000		20000		18000		Form
.0102		tblVolume.Pages * tblMaterial.UnitCost
2		5000		20000		18000		Toner
.000025	tblVolume.Printfeet * tblMaterial.UnitCost

And so on . . . .

The CalcFormula string comes from a table that is keyed to the material
type with the formulas stored as text values.  

I am trying to use the Eval() function to deliver a total cost for each
row.  Using Eval(CalcFormula) results in an error.  However, if I paste
the literal value of CalcFormula into the Eval() function
(Eval(tblVolume.Pieces * tblMaterial.UnitCost), for example), I get a
valid result.  Now, it seems to me that if the literal value of the
CalcFormula field can be made to work with the Eval() function, then I
ought to be able to pass a reference to a text field containing that
value and get the desired result as well.  Obviously, I'm missing
something about using this function.  Can anybody steer me down the
correct path?

Thanks!

Don McGillivray
Sprint Mailing Services


More information about the AccessD mailing list