suppressing zeros in a textbox

M

Michel Peeters

I have a text box in a form linked to a numeric field.
Format is : # ##0;-# ##0;""
Which means the field is blank when value = zero.
Problem: when I click in the textbox, an "unwanted" zero shows up.
Does somebody knows code (or a format setting) to avoid this?
Tks
Michel
 
M

Marshall Barton

Michel said:
I have a text box in a form linked to a numeric field.
Format is : # ##0;-# ##0;""
Which means the field is blank when value = zero.
Problem: when I click in the textbox, an "unwanted" zero shows up.
Does somebody knows code (or a format setting) to avoid this?


That's because the bound field has a value of 0, possibly
because the field's DefaultValue is set to 0. If you don't
want a zero value, then remove the DefaultValue setting in
the table (generally a good idea) and update the table to
set the field to Null in all records with a value of 0 .

Access always tries to display the real value when a text
box received the focus. So, in your case, the formatting
has to be ignored in order to display the value so it can be
edited.

Notes:
Access even goes so far as to change the way the value is
formatted (e.g. unrounded, scientific notation, etc) so you
can see as much of the real value that can fit into the text
box's size. OTOH, if the entire value as formatted by the
Format property will fit AND the formatted value can be
parsed back to the saved value, then the formatted value
will be displayed.

This is a very complex issue, especially when you consider
that the Format property might contain something like
0" cats"
and if Access displayed
7 cats
so an innovative user could try to edit that to
4 birds
What would you propose that Access do with that?
 
M

Michel Peeters

tks, problem solved
Marshall Barton said:
That's because the bound field has a value of 0, possibly
because the field's DefaultValue is set to 0. If you don't
want a zero value, then remove the DefaultValue setting in
the table (generally a good idea) and update the table to
set the field to Null in all records with a value of 0 .

Access always tries to display the real value when a text
box received the focus. So, in your case, the formatting
has to be ignored in order to display the value so it can be
edited.

Notes:
Access even goes so far as to change the way the value is
formatted (e.g. unrounded, scientific notation, etc) so you
can see as much of the real value that can fit into the text
box's size. OTOH, if the entire value as formatted by the
Format property will fit AND the formatted value can be
parsed back to the saved value, then the formatted value
will be displayed.

This is a very complex issue, especially when you consider
that the Format property might contain something like
0" cats"
and if Access displayed
7 cats
so an innovative user could try to edit that to
4 birds
What would you propose that Access do with that?
 

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

Top