Link to home
Start Free TrialLog in
Avatar of MRG_AL
MRG_AL

asked on

Field rounding in Access 2007

I have a formula that runs when the user clicks on a certain field on a form in Access 2007. I have the field set in the table as decimal, fixed, 2 decimal places. I have it set the same way in the form. This works fine if I enter the number but how do I fix this field that is connected to the formula. It keeps rounding to the nearest whole number and I need it to round out 2 decimal places.

I have also tried field = round(2,(field1 - field2)) and that gives me a debug error.
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

You have the parameters switched around...

field = round((field1 - field2),2)

Also, you'll want to throw in Nz to handle any NULLS

field = round((Nz(Me.field1,0) - Nz(field2,0)),2)
Avatar of MRG_AL
MRG_AL

ASKER

It is still rounding but is providing two zeros after the decimal point.

The round equation your provided did work in that it didn't give me an error but I can't get it to calculate out two decimal places still.
My guess is that you have the field in the underlying table defined as an integer.
Avatar of MRG_AL

ASKER

It is set up as a decimal on the table. I have tried double, long integer, and decimal. But I have it as Decimal, 2, fixed

That is what I don't understand. I can type in 2 digits after the decimal on a different field but this one runs through the equation and gives me two zeros everytime?!?!
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MRG_AL

ASKER

It was the Scale on the table. The scale has to be set to 2 and I only had the decimal places set to 2.

Thank you for all your help and advice. The formula works perfect with the rounding now that I have the ,2 at the end of the formula
So, how does the solution you accepted relate to the scale on the table?

Actually, Access doesn't even have a "scale" property for numeric fields, what system is your backend in?
Thanks for the grade, although if this were a SQL Server linked table, with a scale of 0 as you say, then fyed should receive at least partial credit.