Mcgillivray, Donald [ITS]
donald.a.Mcgillivray at mail.sprint.com
Tue Sep 9 12:59:43 CDT 2003
Thanks for the reply, Steve! CalcFormula isn't a function, it's simply a field in the query. Are you saying that I can't pass a simple string value to Eval() - that it has to be a function that returns a string? If that's so, why, when I pass the literal contents of CalcFormula, does it return a valid result? Don -----Original Message----- From: Steve Capistrant [mailto:scapistrant at symphonyinfo.com] Sent: Tuesday, September 09, 2003 10:28 AM To: Access Developers discussion and problem solving Subject: RE: [AccessD] Need help with Eval() function I think Eval requires that you include the parentheses of the function you call. E.g, Eval(CalcFormula()) Also, make sure that CalcFormula is Public and a Function (not a Sub) Steve Capistrant Symphony Information Services scapistrant at symphonyinfo.com Phone: 612-333-1311 www.symphonyinfo.com 212 3rd Ave N, Ste 404 Minneapolis, MN 55401 -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Mcgillivray, Donald [ITS] Sent: Tuesday, September 09, 2003 11:34 AM To: AccessD Subject: [AccessD] Need help with Eval() function 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 _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com