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

  • Thread starter Thread starter Maury Markowitz
  • Start date 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
 
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 "".
 
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.
 
Back
Top