How to add zero's to a number in a field?

M

Maury Markowitz

My forms have many fields where users are typing in large numbers, like
"three million". It's very easy for them to leave off a zero, and get the
number wrong, yet this error isn't very easy to spot.

I would like to add a way that that can type "m" for million, and "t" for
thousand. The system will then replace the t or m with the appropriate number
of zeros. This way the user can type "3m" and get the right value every time.
h would give a hundred, so typing "3ht" would add two zeros and then three,
making a hundred thousand.

I'm having trouble writing this function. I tried attaching it to the
_Change message, but after I add the zeros and apply the change back to the
form that, of course, fires the _Change.

I suppose I could add it to the _KeyDown and manipulate the number, but this
would be difficult to add to every single field in the entire app.

I could also add it to my _AfterUpdate, but the problem is some of these
fields already have a macro attached to this event.

So is there some way to either...

1) make a custom formatter I could apply to all of these fields?
2) use a macro that could be applied to any field?

Thanks!

Maury
 
J

James Hahn

Your present procedure should work, because after you detect a m or t or h
and make the required change, the m or t or h no longer exists, so when the
change event fires again nothing gets changed the second time (there is no
more m or t or h). You just have to make sure you are testing correctly for
whether or not you need to change something, and make sure you don't change
anything if you don't have to.
 
Top