Ensure textbox holds 2 decimals

rockies1

King Cobra
Local time
Today, 00:31
Joined
May 21, 2001
Messages
38
How can I ensure that my user enters a value that would be valid currency?

For example, I would accept 1 or 1.2 or 1.23 but not 1.234.

If I set the textbox format to Currency, it shows 1.234 as $1.23 but the .text is still 1.234.

Thank you!
 
Try using an input mask. Under properties of that control, Data, use the input mask wiz to create one to suit currency.....
 
In the table..or form..if you chose...set the fields formatting. Use two 00 (zeros) after a . (decimal point) to indicate that the user must provide two digits after the decimal point.

0.00;(0.00);;0.00

The first part says that normal values should be represented using at least one number before and two numbers after the decimal place.

The next part says that negative numbers should be in parens.

The last part says that if the field is null, default to 0.00

Hope this helps!
 
The problem with that is if I enter 1.234 it will show 1.23 but
Code:
MsgBox Me.TxtBox
will show 1.234

I need to actually prevent any more than 2 decimals, not just format it so it looks like 2 decimals.
 
Okay...well...then Sebby was right....you'll have to use and input mask!

Will you be limiting the numbers before the decimal point? If you will...then consider limiting the field size...that will help to prevent people from entering to much...but the input mask will work better.


Use # for digits that might be used....but can be left blank and 0 (zeros) for the digits that are required!

Or select one of the preset input masks!
 
OK, any ideas how I would create one that would allow unlimited dollars and only 2 decimals, but would accept any of the following as valid?

1
1.2
1.23
11111111111.2
11111111111.23

I tried #.## but it only allowed 1 dollar number.
 
Remember that # is a place holder that can be left empty or filled. if you want to force two decimal points...you've have to go with

!99999999.00

I'm sorry about misleading you on the #. I forgot that # will become a space if not filled in. 9 will just be blank

The ! doesn't have to be used, but it might be a litte less frustrating having the users SPACE over to the number pf places they wish to fill in. ! fills in from right to left!
 
I assume that the text box feeds into a field in a table. If it does you could also change the field properties to Number, Type Decimal with a scale of 2 and a decimal places of 2

That is what I had to do this morning

All the Best

Toni
 

Users who are viewing this thread

Back
Top Bottom