What edit mask to use....

  • Thread starter Thread starter Brad Pears
  • Start date Start date
B

Brad Pears

I have a form field where I want the field to display as blank (no zero) in
it for initial data entry. However, the underlying table has a default value
of 0 in it for that particular field and I want to keep it that way. What
edit mask can I use so that the "0" does not display as the default value in
the field?

Thanks,

Brad
 
Is the field a number field? If so, it will default to zero. If it is a
text field, it will (most likely) default to null.
 
Yes, the field is an integer. If the field is left blank, I wnat the
underlying table to stiull have a 0 value. I'll explain the problem and
maybe you can suggest an alternative...

I have an application where I was defaulting to 0's for numeric fields.
Problem is that when the user enters a value in there, unless they have
insert turned off, if they enter a value of 10 for instance, it shows as 100
because of the 0 that was already there. This is a pricing app and they are
scared they may wind up overpricing stuff if they arent; careful. on some
fields I can place restrictions like >0 and <50 for instance to catch that
type of thing but not on all fields. Since they are too lazy to just
highlght the field could I automatically select the text in there on focus
event?? Likely I guess. Maybe that would solve the issue...

Thanks, Brad
 
How are they getting to that field? If they are in a form and they tab to
it, I'd expect it to highlight the entire field. If it is not, you might
check your TOOLS/OPTIONS/KEYBOARD/BEHAVIOR ENTERING FIELD setting.

I've built hundreds of numeric fields and never had to do anything unusual
to compensate for a "zero" value in the field. I've never had trouble with
users accidentally entering a number to the left of that zero and making it
10 times the intended entry.
 
Well, yes, if they tab to it, it does highlite the entire field. But, if
they siomply click on it with their mouse, it does not. Not to worry though,
I discovered that I can use the .selstart and .sellength properities (see
below example) in the "on click" event to specify that when the user
"clicks" on that textbox, it highlites the entire field.

Placing that code in the "got focus" event does not work as the click event
runs immediately after that - which "deselects" the field!! That's why the
code needs to be placed in the "on click" event.

Thanks for your input.

Sub WindowQty_Click()
' select the text
Me.WindowQty.SelStart = 0
Me.WindowQty.SelLength = Len(Me.WindowQty)
end sub
 
I'd agree with Rick. It's something that I've never seen happen either.
But, to get the effect you're asking for...

Make the text box unbound. (call it t1)

Add another text box that is bound to the field, and hide it. (call that t2)

In the current event of the form...
if me.t2=0 then
me.t1=""
else
me.t1=me.t2
endif

And in the after update event of t1...
me.t2=nz(me.t1,0)
 
Hmmm. Just to drag out the old quote... make something idiot proof and
they'll just build a better idiot.
 
Back
Top