Home > Net >  How to Limit Decimal Places in Access
How to Limit Decimal Places in Access

Time:01-07

In access I have tried just about everyway I can find to set the number of decimal places to 4 for a double variable yet I get 10 digits after the decimal

I have tried:

  1. Table design field properties
  2. Control properties
  3. Round([variable/control],4)

Does anyone have a suggestion on how to ACTUALLY limit decimal places?

EDIT: Had an idea and will try this next Only other thing I can think of is to use a MID/RIGHT function to cut the extra decimal places?

CodePudding user response:

Use (convert to) data type Currency. It holds exactly four decimals maximum.

Also, in VBA, you can do:

Dim Value4 As Currency
Value4 = CCur(YourDoubleVariable)

CodePudding user response:

As Gustav said, you can use Currency, or you can use Number/Decimal, where you can specify the number of decimals.
Both Currency and Decimal will also avoid reduce trouble with rounding totals.
I think that Decimal type does not exist in VBA so your variables should be Variant.

  •  Tags:  
  • Related