Replacing blank fields with zero

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top