a precent input problem

bobination

New member
Local time
Today, 14:55
Joined
Jun 20, 2007
Messages
2
Hi all.
I seem to have a problem with precebt field input.
When I enter the data it either multiplys by a hundred, of becoming zero.
I naturally want the range to be from zero to hundred.

Anyone got an idea how I can format it in the form, when entering data?

Thanks
 
store the data in the table as type double, format percent

when you enter you either need to type

5.2% (ie type the percent sign)

if you don't then typing 5.2 will be taken as 520%

so you would need to type 0.052 to get 5.2% which is not obvious

i think you could also use an input mask to accept the input
 
I've already done that but...

I saw at a very early stage of my work that I should use double and precent format, however - an input mask won't work on this data-type.

What I eventually want to create is a form in which my users could type in a number, say 10, and get the input to be 10%.

Isn't there some way to add the % sign after the input has received, and only then send it in the table?

After all, friendly MMI is everything...
 
Just in case anyone ever finds this thread again, here may be a way to make this work (at least, it is working for me).

In the VBA code for your form, add a new variable (like DIM value as Double) before any of your Subs. This allows this variable to be accessed by any of the subs.

Set the "On Entry" for the field in your form via VB code like the following:
value = MyField

Set the "On Exit" for the field like this:
If MyField <> value Then
MyField = MyField / 100
End If

In essence, what you are doing is storing the initial value of the field when you first give it forcus before you mess with it. Then, the on exit checks to see if you have changed the value of the field. If you have, it divides it by 100 to make it be the correct percentage (since the average user would enter it as a 5 when they mean something like 5%). If you haven't changed it, it leaves it alone (this prevents you from dividing the value by 100 every time that you exit the field, whether you changed it or not).

I haven't found any bugs in this as of yet. So, if anyone finds anything wrong with it, please post again!

Enjoy~
 
Make note if you ever plan to update the DB to Access 2007... The percentage problem has been fixed in 2007....So if you update... You'll have to remove your code.
 

Users who are viewing this thread

Back
Top Bottom