Form Error Nz

shamas21

Registered User.
Local time
Today, 22:56
Joined
May 27, 2008
Messages
162
Hi All

I have the following expression in my text box. But sometimes it return #Error. How can i trap this error so if it occurs then it will read 0.

Thanks
 
what's the expression?
 
Whatever = Nz(FieldName, 0)

Will return zero if FieldName is Null.
 
Also, if your expression does something like division, you can still have an error if you wind up dividing by zero. Hard to say what it is without more information.
 
As usual, Bob raises a good point. What I usually do, if I have a field that will be used as a divisor, such as

Field1/Field2

is use

Nz(Field2, 1)

so I'd end up with

Nz(Field1, 0) / Nz(Field2, 1)

If Field2 is left Null, then Field1 will be divided by 1, which actually means that it's left undivided. If the Null Field2 was simply overlooked, no error will be raised. On the other hand, if the user left Field2 blank, on purpose, because they didn't want Field1 divided, that will also be accomplished.
 

Users who are viewing this thread

Back
Top Bottom