Rounding off numbers. (1 Viewer)

Fuga

Registered User.
Local time
Today, 22:13
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.
 

Fuga

Registered User.
Local time
Today, 22:13
Joined
Feb 28, 2002
Messages
566
Hmm..

I get a "undefined function" message...

What am I doing wrong?

Fuga.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 15:13
Joined
Feb 28, 2001
Messages
27,192
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

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

Registered User.
Local time
Today, 21:13
Joined
Jan 8, 2002
Messages
32
Careful with the Int() function. It looks like it is rounding but it is truncating instead. So 7.9 becomes 7...
 

Alexandre

Registered User.
Local time
Tomorrow, 03:13
Joined
Feb 22, 2001
Messages
794
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
 
J

Jerry Stoner

Guest
NeatCode97

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

Alexandre

Registered User.
Local time
Tomorrow, 03:13
Joined
Feb 22, 2001
Messages
794
Hi Jerry,

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

Alexandre

Registered User.
Local time
Tomorrow, 03:13
Joined
Feb 22, 2001
Messages
794
Yeah. Luddites are endangered species nowadays :p
(But not as much as people calling me heavyweight. Trust my word :D )
 

pcs

Registered User.
Local time
Today, 15:13
Joined
May 19, 2001
Messages
398
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

Registered User.
Local time
Tomorrow, 03:13
Joined
Feb 22, 2001
Messages
794
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:

Alexandre

Registered User.
Local time
Tomorrow, 03:13
Joined
Feb 22, 2001
Messages
794
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
 
R

Rich

Guest
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

Registered User.
Local time
Tomorrow, 03:13
Joined
Feb 22, 2001
Messages
794
I guess B. Gates would readily reply: 'Wait and upgrade to WXXP and A XXP' :(
 
J

Jerry Stoner

Guest
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

Top Bottom