Below is a vary simple problem description of what I am trying to accomplish
I have a table with 3 fields in it:
Formula - text
A - double
B - double.
The value of each variables is:
Formula= A * B
A = 2
B = 4
I want to read each record in the table and apply the formula to the numeric values. The formula is not constant. It changes with each record and may have more than one mathematical operator within the formula. For example (A ^ 2) + (B ^ 2).
This is a section of the code that I am trying to run:
While Not rs.EOF
Formula = rs(0)
A = rs(1)
B = rs(2)
Answer = A * B
rs.MoveNext
Wend
I would like to use something like:
Answer = Formula
but when I use the syntax I get Type mismatch error.
If I use this:
Answer = Eval(Formula)
I get an error that reads "Microsoft Access can't find the name 'A' you entered in the expression."
Any ideas on how to make the code resolve the text string FORMULA to apply the mathematical operators?
I have a table with 3 fields in it:
Formula - text
A - double
B - double.
The value of each variables is:
Formula= A * B
A = 2
B = 4
I want to read each record in the table and apply the formula to the numeric values. The formula is not constant. It changes with each record and may have more than one mathematical operator within the formula. For example (A ^ 2) + (B ^ 2).
This is a section of the code that I am trying to run:
While Not rs.EOF
Formula = rs(0)
A = rs(1)
B = rs(2)
Answer = A * B
rs.MoveNext
Wend
I would like to use something like:
Answer = Formula
but when I use the syntax I get Type mismatch error.
If I use this:
Answer = Eval(Formula)
I get an error that reads "Microsoft Access can't find the name 'A' you entered in the expression."
Any ideas on how to make the code resolve the text string FORMULA to apply the mathematical operators?