Help with formatting decimal places in calculated query field

BJF

Registered User.
Local time
Today, 16:54
Joined
Feb 19, 2010
Messages
140
Hello,

I am having trouble getting the correct syntax to format a query field that is a calculation.

Please help!

This is my expression in my query field: the name of the field is 48 and the calculation is working correctly for me however there are like 10 decimal places and I want only 3.



48: ((36/48)*(([Yards]*36)*[Inches])/1296)



I have tried the following 2 ways below but still can’t get it into my query without a too many parenthesis error.



Format([48: ((36/48)*(([Yards]*36)*[Inches])/1296)], “0.000”)

48: Format(((36/48)*(([Yards]*36)*[Inches])/1296), “0.000”)



Thanks in advance for any assistance.

BJF
 
I should also note that the properties box does not work when i set the decimal value to 3 decimal places.
The properties box does not affect my calculated number at all no matter what i set it to.
 
the format function provides a text result - use the round function

48: round(((36/48)*(([Yards]*36)*[Inches])/1296))

and 48 is a dreadful name for a field - it will get you into trouble
 
If this works:

48: ((36/48)*(([Yards]*36)*[Inches])/1296)

Then you correctly added the format in the second version

48: Format( ((36/48)*(([Yards]*36)*[Inches])/1296) , "0.000")

So not sure why the second version didn't work.
 
the format function provides a text result - use the round function

48: round(((36/48)*(([Yards]*36)*[Inches])/1296))

and 48 is a dreadful name for a field - it will get you into trouble
Thanks so much CJ! I will change the filed name to text as well
 
I don’t recall having set a format in the query since formatting can easily be set in a control on a form or report.
 
The query gives you the result of the calculation: formatting should be done when that result is used.
 
Rounding is the conversion of a value from a higher precision to a lower precision. Prematurely rounding the return value of an expression is, in most contexts, inadvisable because, if the value is then used in further arithmetical operations, the lower precision is fed into those operations. This can result in the final value of a series of operations being significantly different from the actual value in the real world. Say for instance you are building a brick structure of a series of bays. If you compute the width of each bay by, assuming stretcher bonding is used, multiplying the length of each brick + the width of the joint by the number of bricks per bay, and then round the value before multiplying it by the number of bays to give the length of the structure, the lower precision per bay will be multiplied, and the computed length of the structure can differ significantly from the length on the ground. If, on the other hand, no rounding is undertaken until the final operation, computing the length of the structure, then the result will be correct to whatever precision is applied to the final expression.
 

Users who are viewing this thread

Back
Top Bottom