Eval() field values from within text boxes????

G

Guest

In Access 2000 I have one table containing a field
called 'Function' where the user enters a mathematical
function. A second table contains VarA and
VarB. 'Function' will refer to VarA and VarB within the
function entered.

I want to join the tables in a query and use the Eval
function in a 4th calculated field to evaluate the
contents of the Function text box and produce a result
depending on the contents of the VarA and VarB fields in
the that particular joined record.

My issue is that the Eval function works well to evaluate
simple mathematical expressions entered into the Function
text box but I can't get it to refer in the expression to
the VarA and B fields. If I write a function within the
Eval code it works fine, but if I enter the variable into
the text box for Function it doesn't work - it can't seem
to evaluate the variable. It doesn't recognise the
contents of the text box as containing field names /
variables. Can someone help?

Many thanks,
Brad

Many thanks,
Brad
 
P

Paul Overway

Supposing you had a query with columns VarA and VarB and you wanted to
perform the following calculation:

VarA + 10 * (VarB/20)

Your Eval statement should look like this:

Eval([VarA] & " + 10 * (" & [VarB] & "/20)")

Basically, you need to construct a string that can be evaluated.

HTH
 
G

Guest

Hi

thanks.

However even if I enter simply [VarA] in the field, the
eval function can't work it out - gives an error. The Eval
function doesn't know it is a field / variable. If I write
the function in the query as Eval([VarA]) then it works
ok, but the point is not to hard code it.

Would welcome any further advice.

Thanks,
Brad
-----Original Message-----
Supposing you had a query with columns VarA and VarB and you wanted to
perform the following calculation:

VarA + 10 * (VarB/20)

Your Eval statement should look like this:

Eval([VarA] & " + 10 * (" & [VarB] & "/20)")

Basically, you need to construct a string that can be evaluated.

HTH

--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com


In Access 2000 I have one table containing a field
called 'Function' where the user enters a mathematical
function. A second table contains VarA and
VarB. 'Function' will refer to VarA and VarB within the
function entered.

I want to join the tables in a query and use the Eval
function in a 4th calculated field to evaluate the
contents of the Function text box and produce a result
depending on the contents of the VarA and VarB fields in
the that particular joined record.

My issue is that the Eval function works well to evaluate
simple mathematical expressions entered into the Function
text box but I can't get it to refer in the expression to
the VarA and B fields. If I write a function within the
Eval code it works fine, but if I enter the variable into
the text box for Function it doesn't work - it can't seem
to evaluate the variable. It doesn't recognise the
contents of the text box as containing field names /
variables. Can someone help?

Many thanks,
Brad

Many thanks,
Brad


.
 

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