Trying to avoid the display of "#Error" in a calculated field

  • Thread starter Maury Markowitz
  • Start date
M

Maury Markowitz

I have a continuous forms layout with a field that returns the value
from a calculation Function in the form's module. The function relies
on two inputs being typed into separate fields at the top of the form.
If they aren't there, the system gets an error in the calculation,
which is fine, but the field reads "#Error". That's ugly, I'd rather
it simply be blank.

I tried several variations of Iif and IsError, but nothing worked.
Then I tried nothing more than =IsError(calculate()), and THAT
returned #Error. I assume that's because the missing values throw an
exception?

If so, what's a good approach to this problem?

Maury
 
D

Dale Fye

I assume that the function "Calculate()" reads the values of the two controls
at the top (I'm assuming this means in the forms header) of the form. If
that is the case, then modify the function so that it checks to see if either
value is blank (Null or empty), and if so, have the function return a "".
 
S

Stuart McCall

Maury Markowitz said:
I have a continuous forms layout with a field that returns the value
from a calculation Function in the form's module. The function relies
on two inputs being typed into separate fields at the top of the form.
If they aren't there, the system gets an error in the calculation,
which is fine, but the field reads "#Error". That's ugly, I'd rather
it simply be blank.

I tried several variations of Iif and IsError, but nothing worked.
Then I tried nothing more than =IsError(calculate()), and THAT
returned #Error. I assume that's because the missing values throw an
exception?

If so, what's a good approach to this problem?

Maury

Instead of 'pulling' the calculation from the function via a property
expression, try 'pushing' the data from the 'separate fields' via their
AfterUpdate events:

Private Sub Field1_AfterUpdate()
CalcDisplayControl = MyFunction()
End Sub

Same for Field2.
 

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