Replacing blank fields with zero

M

Mr. Smiley

Is there a piece of code that I can put into a form that states if the field
is blank then display a zero value? Thanks.
 
A

Allen Browne

Just set the Format property of your text box so it display a zero (or a
dash or anything you like) for null.

Example of what to put in the Format property:
#,##0; -#,##0;0;0
 
O

Ofer

If it is a field for display only, you can use the NZ function in the control
source of the field

=Nz([FieldName],0)

If it is a field that you want to update, but you want to avoid the user
changing the 0 to Null, then you can set the default of the field to 0, and
on the before update event of the field you can write the code

Me.FieldName = Nz(Me.FieldName,0)
 
Top