Error handler not working

dimitri

Registered User.
Local time
Today, 01:32
Joined
Oct 9, 2012
Messages
18
There is simple function to check if the variable has a value and if not set then set it to zero,

Function nulltozero(anyValue As Variant) As Variant

If IsNull(anyValue) Or anyValue = "" Then
nulltozero = 0
Else
nulltozero = anyValue
End If
exit_NulltoZero:
Exit Function
err_NulltoZero:
nulltozero = 0
Resume exit_NulltoZero

End Function

This function is set on the control source of a textbox as "=nulltozero(subPreview.Form!txtTotal)"

When the form loads, the txtTotal is empty and has no value. so the value should be set to 0 but this is the error that I am getting

Run time error '2427': You entered an expression that has no value

Your help is appreciated

Thanks
 
If the subform has no records, then you get problems. For this type of thing I use the functions IsError and IIF
 
pbaldy - you are the boss, thanks that ( If Not (IsNumeric() ) helped. I had tried NZ and it did not work.. Spike, I will try your solution too..

Thanks again
 

Users who are viewing this thread

Back
Top Bottom