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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

round function!!

Status
Not open for further replies.

kingz2000

Programmer
May 28, 2002
304
DE
Hi Guys,

one really annoying thing I'm encountering is that round(x,2) instead of giving me 2 decimal places gives me a 2 digit integer - Why?

 
That's what Round() is supposed to do!
msdn said:
Round Function
See Also Example Specifics

Description

Returns a number rounded to a specified number of decimal places

I really can't understand what you are trying to do, please give an example.

Simon Rouse


 

I'm using the following formula:

=round(Sum([Bar_NL])/[txtsum]*100,2) & '%'


Bar_NL = 4 & txtsum = 7

I am basically trying to get 4/7*100 rounded to 2 decimal places.I get '57%'!! I want 57.14%!!What am I doing wrong?
 
Apologies for appearing so rude. I really didn't read your question properly!
I can't see anything wrong with your formula and it worked fine for me. What I do in these circumstances is to decompose the function and find out what aspect causing the problem. I'd try first removing & '&' , then *100 and see what happens each time.
The one thing that stuck me as being a bit on was that you were dividing a Sum by a single record value and as far as can think that would always use the one preceding the footer. OF course that would only affect the result not the decimal places which is what you as having trouble with.

As regards an explanation: my aphorism is 'Computers are only human after all'
Simon Rouse
 
As an alternative, which may or may not be appropriate depending on how you intend to use the result, why not try:
Code:
=Format(Sum([Bar_NL])/[txtsum],"0.00%")
Hope this is of use.

[pc2]
 
'Format' doesn't work at all!!:(

..and I'm still trying to find the reason it won't give me the right answer...grrrrr
 
I think there is really something odd going on here.
a) What version of Access are you working on?
b) Could your database be corrupt in some way? How about creating a new database and copy over relevant tables and the report and try again?
 
before the '=' sign? nothing!!

I'm using access 2000. Database isn't corrupt!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top