View Full Version : Rounding off numbers.


Fuga
06-06-2002, 01:21 PM
I´m using a graph on a form to show the temperature a given time of day.

I wanted to display it as a "normal distribution" so I use the count function, i e access is counting the number of observations having a certain value.

The problem is there are a lot of decimals in the values, making almost every observation unique. I´m not interested in that much accuracy. Three decimals will do, and then a lot of observations will group together.

So, in the query I use for the graph, how do I round off the numbers to three decimals?

Fuga.

Sohaila Taravati
06-06-2002, 01:25 PM
Number: Round([Yourfield],3)

Sohaila

Fuga
06-07-2002, 09:23 AM
Hmm..

I get a "undefined function" message...

What am I doing wrong?

Fuga.

The_Doc_Man
06-07-2002, 09:45 AM
Which version of Access are you using. If it is Ac97, "Round" is not necessarily one of your function options.

You might try this:

dfRoundedTemp = CDbl( CLng( 1000.0 * dfTemperature)) / 1000.0

This assumes you are using a Double number for the temperatures.

Fuga
06-09-2002, 08:34 AM
Yes, I´m using ac97.

I looked around a bit, and now I´m using the Int function.

It seems to be working.

Fuga.

jesseb
07-23-2002, 09:19 AM
Careful with the Int() function. It looks like it is rounding but it is truncating instead. So 7.9 becomes 7...

Alexandre
07-23-2002, 02:32 PM
From NeatCode97

Function RoundN(x, N As Integer)
'
' Rounds a number to N decimal places
' Uses arithmatic rounding
' N should be in the range 0-10 for proper results
'
Dim Factor As Long
Factor = 10 ^ N
RoundN = Int(x * Factor + 0.5) / Factor
End Function

Jerry Stoner
07-23-2002, 02:40 PM
Hi Alexandre, if you're still speaking to me :), what is NeatCode97 and where can I find it?

Alexandre
07-23-2002, 03:56 PM
Hi Jerry,

NeatCode is an MS free sample database with a variety of code snippets, downloadable from the MS Site.

pcs
07-23-2002, 04:04 PM
jerry,

glad alex is still speaking to you :)

don't know if these url's will make it through this post intact...

bunches of A97 stuff:

http://www.microsoft.com/downloads/searchdl.asp?Search=Product&LangIDCODE=20%3Ben-us&Value=3&OpSysID=1311&Show=Alpha

neatcode97:

http://www.microsoft.com/downloads/release.asp?ReleaseID=13975&LangID=20&LangDIR=en-us&OpSysID=1311&Search=Keywords&Value=neatcode&Show=Alpha&Start=&Page=0

better get them while the are still on the MS site! :(

hth,
al

Alexandre
07-23-2002, 04:30 PM
Yeah. Luddites are endangered species nowadays :p
(But not as much as people calling me heavyweight. Trust my word :D )

pcs
07-23-2002, 04:52 PM
alex,
your word is always trusted!

i guess i am a 'heavyweight' Luddite!

and i am nearly 'shoeless' (sans sabots?). but, it is due to my poverty keeping up with all the changes as i try to maintain Bill G.'s cash-flow and life-style!

in a more perfect world, 'crap features and market hype' would not replace real software improvements.

al

Alexandre
07-23-2002, 05:27 PM
pcs,

I suscribe to your point 100%. As a matter of fact, A2k was widely recognized not being worth the upgrade but eventually for 2(!) features: replications improvements and subdatasheets. Needless to say that one has to be very keen on that to consider upgrading in such conditions... And this is where the 'soon-we-will-not-support-previous-versions-anymore' politics com into play to convince the sceptical masses...:mad:

As for me, I am afraid I came (directly) to A2k in a way that will never contribute to Bill G.'s cash-flow and life-style...

BTW, 'sans sabots' was a nice try. Sounds somewhat old-fashioned and poetic. ;)

Rich
07-23-2002, 10:27 PM
I've earlier versions for sale, if your interested Fat boy slim:D

Alexandre
07-24-2002, 12:24 AM
For WHAT? ;)
Earlier versions... You mean Access 1.0 and 2.0? I didn't know that you were a collector. Or is it sentimentalism?:p

Anyway, I may consider a donation, just for your own sake (extinction is getting close) and to see if you still lurk around these fora for the next future :D

Rich
07-24-2002, 12:46 AM
I spotted this post elsewhere the other day Alex and I didn't know what to say
Help: a simple function I have which took 1 minute to run in 97 now takes 45 in XP what can I do?
Any ideas?

Alexandre
07-24-2002, 01:59 AM
I guess B. Gates would readily reply: 'Wait and upgrade to WXXP and A XXP' :(

Jerry Stoner
07-24-2002, 06:34 AM
Very usefull code. So... how do I ever live down my transgressions? One little slip and ...oh the pain!