Do Not Display Default Value

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

Hi,

I have a form with unbound text boxes, the users can enter data into the
text boxes and this data is then saved into a table. If the user does not
enter a value in the text box, I want to populate the table with a 0.00
value. The best way I though to do this was using a default value, but I
don;t want to see it in the text box on the form.

I need to do this because when I sum the values and if any are null the
total becomes null.

Any ideas?
Thanks

Simon
 
Simon said:
Hi,

I have a form with unbound text boxes, the users can enter data into the
text boxes and this data is then saved into a table. If the user does not
enter a value in the text box, I want to populate the table with a 0.00
value. The best way I though to do this was using a default value, but I
don;t want to see it in the text box on the form.

I need to do this because when I sum the values and if any are null the
total becomes null.

Use a Default Value in the table, and delete it as a form property. You can
also, force the value in the form's Before or After Update events.

Sub Form_AfterUpdate()
If Len(Me.TextboxName & vbNullString) = 0 Then
Me.TextboxName = 0
End If
End Sub
 
Simon said:
Hi,

I have a form with unbound text boxes, the users can enter data into the
text boxes and this data is then saved into a table. If the user does not
enter a value in the text box, I want to populate the table with a 0.00
value. The best way I though to do this was using a default value, but I
don;t want to see it in the text box on the form.

I need to do this because when I sum the values and if any are null the
total becomes null.

Any ideas?

Check out the nul-to-zero (Nz) function.

Keith.
www.keithwilby.co.uk
 
Peter,
I am using 2007.
Keith Wilby mentioned a function called Nz() which solved my problem.
 
Arvin,
Thanks for your reply
I have numerous box and to write these IF statement for each one would be
quite messy.
Keith Wilby and mentioned a function called nz() which works great.
 
Simon,

I agree, that is your best option.

The reason I asked what version of Access you are using is that the
later versions have a Form property called 'Fetch Defaults' which
hides the default values in the 'New' record when it is set to No (it
defaults to Yes). However, that only works for Bound forms which I see
you are not using, but it might be useful to know for future designs.

Incidentally, I suggest that if you need to ask further questions in
this newsgroup, you also mention which version you are using,
(especially as you are using Aceess 2007 which is very different from
earlier versions) as it can make a difference to the answers you get.

Anyway, good luck with your project.

Peter Hibbs.
 
Back
Top