Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove Default Value of 0

Status
Not open for further replies.

dunkyn

Technical User
Apr 30, 2001
194
US
I have a form that displays 0 by default in some fields, but not others. The default value property does not contain any variable. How do I suppres the 0 so that it does not display?

 
If the Default value property is blank then the Zero(0) is coming from the field in the table. The control source for the form object indicates which field is being displayed. If you do not want a zero(0) to show then you can change the display with a modification of the Format property to #,###. This will display a digit if there is one or nothing if the value is 0. Now the value of the field is still 0 but you are just displaying nothing.

This should help. Bob Scriver
 
I've a question related to this.

What if 0 is an acceptable number for a field? I have many text boxes that will allow a 0 but I do not want it to display a 0 in every box that has not had anything entered into it. Makes my printout look a touch funny...

Thanks,
MajorYoshi
 
MajorYoshi,

Go to the Table in design view for this field. In the Default Value for this field see if there is a 0. If so, remove it and see if it still shows up in your form.
 
Change the default value at the table level to Null. Problem is that this doesn't convert all of the already created records to this value. So, if you have a functioning database those records will have to be updated with a Null value in the numeric fields. Run a query to update the fields with Null.

Now you should get a blank in the beginning and a Zero(0) only when they enter a zero value.

You must take care if you are making calculations with this field setup this way. Nulls and Zero values must be tested for when using them in expressions. Functions like NZ, IIF, and Switch can be used to control errors that may crop up if used in an expression.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Thank you both for your time. It looks much better now (and point learned about using nulls!)

Be well,
MajorYoshi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top