Eval() #Error

K

Kevin Sprinkel

I am simulating an Excel spreadsheet, wherein the user may
enter a number or a formula into a textbox on a continuous
form. The adjacent cell, txtResult, calculates the
result. Its control source is:

=Eval(Nz([txtFormula]))

The BeforeUpdate event of txtFormula assures that a valid
formula has been entered.

Everything works fine, except that before a formula has
been entered in a new record, txtResult
displays "#Error". I don't understand why--doesn't the Nz
call convert a null to zero? I would therefore expect
txtResult to display zero.

Someone, please let me know where I've gone astray.

TIA
Kevin Sprinkel
 
G

Gerald Stanley

The help file indicates that the Nz function would return a
zero length string when the context of the first parameter
indicates a string and the second parameter is not
provided. I would advise giving =Eval(Nz([txtFormula], 0))
a try.

Hope That Helps
Gerald Stanley MCSD
 
A

Allen Browne

Nz() will not be able to interpret the forumla.

Perhaps:
=IIf([txtFormula] Is Null, 0, Eval([txtFormula]))
 

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

Similar Threads

Disabling a Control On Exit 2
Totals Not Working 4
Type Mismatch In Expression 5
Eval() Problem 4
Invalid Reference Error 8
Re-Insert Null value into database field 3
#Error msg on form 8
Hiding error message 3

Top