Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format number in query

Status
Not open for further replies.

Hillary

Programmer
Feb 15, 2002
377
US
First, in my query, I am dividing Total Value by Ending Balance. Because parts were bought at different cost, some the values returned are 18 places to the right of the decimal. (example: .013333333333333333) In the Field Properties I have set the Format to General Number and the Decimal Places to 2 but it has no effect on how the query is displayed. How do I round to a 2 place decimal?

Secondly, same situation but I have an IF statement where the truepart returns a string and the falsepart returns a calculation. There is no decimal option on the Field Properties. How do I round to a 2 place decimal?

Thanks for your help.

Hillary
 
Hi

In your query put a calculated column:

Result:Format(Total Value/Ending Balance,"########.##")

or possibly

Result:CCur(Total Value/Ending Balance)

Same idea (ie Format) should work for your IIF situation Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
You cannot "Format" a value with "General Number" Select a differnt type (of number).

Another consideration MIGHT be where the query results are used. If it is for a form/report field, it makes more sense (to me) to do the formatting in the destination object, as opposed to the query itself.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Thanks guys for your help.

I changed the Format from General Number to Standard and the query now reads the Decimal Places in the Field Properties.

On the other issue, I was not successful using Format(Total Value/Ending Balance,"########.##"). I kept getting an error in the date format. When I use the CCur(Total Value/Ending Balance) it defaults to 4 decimal places. Any idea on how to round to a whole number? Do you know if there is a list of these codes published anywhere?

Thanks,
Hillary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top