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
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