P
Phil
I'm an amateur and working on a module that uses values
entered by a user in form to fill in variables in an
equation. Its then solved and the answer output to the
form. The equation changes though based on the user's
selection in a listbox and is stored as a string
variable "E".
The problem I'm having is in the calculation. I can't seem
to get the user input variables to fill in the equation.
Both the equation string and the user's variables have the
same "L" and "W" designation. I thought this would
automatically fill-in-the-blank on the equations. When
that failed, I tried to pass the equation to the EVAL
function, but also failed. The one clue I have is that I
can enter the equation exactly as stored in the table
extracted from and it solves it wonderfully. What am I
missing? My code is shown below. Thanks in advance for
your help.
'on error resume next
Dim L As Single
Dim W As Single
Dim A As Single
Dim E As String
L = Forms!fCalc.tbxLen.Value 'store user specified
length in L
W = Forms!fCalc.tbxWid.Value 'store user specified
girth in W
'Find the equation to use based on users selection in list
box and store in E
E = DLookup("Equation", "tOptions", "Forms!
fCalc.lbxOptions = [OptionsID]")
'Fill in user variables and calculate equation
A = Eval(E)
'Output result to form
Forms!fCalc.lblAMain.Caption = A
Forms!fCalc.lblAShdw.Caption = A
entered by a user in form to fill in variables in an
equation. Its then solved and the answer output to the
form. The equation changes though based on the user's
selection in a listbox and is stored as a string
variable "E".
The problem I'm having is in the calculation. I can't seem
to get the user input variables to fill in the equation.
Both the equation string and the user's variables have the
same "L" and "W" designation. I thought this would
automatically fill-in-the-blank on the equations. When
that failed, I tried to pass the equation to the EVAL
function, but also failed. The one clue I have is that I
can enter the equation exactly as stored in the table
extracted from and it solves it wonderfully. What am I
missing? My code is shown below. Thanks in advance for
your help.
'on error resume next
Dim L As Single
Dim W As Single
Dim A As Single
Dim E As String
L = Forms!fCalc.tbxLen.Value 'store user specified
length in L
W = Forms!fCalc.tbxWid.Value 'store user specified
girth in W
'Find the equation to use based on users selection in list
box and store in E
E = DLookup("Equation", "tOptions", "Forms!
fCalc.lbxOptions = [OptionsID]")
'Fill in user variables and calculate equation
A = Eval(E)
'Output result to form
Forms!fCalc.lblAMain.Caption = A
Forms!fCalc.lblAShdw.Caption = A