Rounding off numbers.

Fuga

Registered User.
Local time
Today, 22:34
Joined
Feb 28, 2002
Messages
566
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.
 
Hmm..

I get a "undefined function" message...

What am I doing wrong?

Fuga.
 
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.
 
Yes, I´m using ac97.

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

It seems to be working.

Fuga.
 
Careful with the Int() function. It looks like it is rounding but it is truncating instead. So 7.9 becomes 7...
 
From NeatCode97
Code:
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
 
NeatCode97

Hi Alexandre, if you're still speaking to me :), what is NeatCode97 and where can I find it?
 
Hi Jerry,

NeatCode is an MS free sample database with a variety of code snippets, downloadable from the MS Site.
 
Yeah. Luddites are endangered species nowadays :p
(But not as much as people calling me heavyweight. Trust my word :D )
 
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
 
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. ;)
 
Last edited:
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
 
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?
 
I guess B. Gates would readily reply: 'Wait and upgrade to WXXP and A XXP' :(
 
Thank You Alexandre and pcs

Very usefull code. So... how do I ever live down my transgressions? One little slip and ...oh the pain!
 

Users who are viewing this thread

Back
Top Bottom