Looking for a faster solution to a rounding function in access query.

I am looking to see if there is a faster alternative to the Rounding function we picked up from a previous question posted. Currently using a function called Round16. It looks like;

Public Function Round16(ByVal v As Double, Optional ByVal lngDecimals As Long = 0) As Double
' by Filipe Lage, fclage-NO~SPAM@kiss-ezlink.com, 20050322
  Round16 = CDbl(Format$(v * 10 ^ lngDecimals, "0")) / 10 ^ lngDecimals
End Function

This is working properly but it is slow. Anyone know of a faster alternative to this? The built in Round() function is not rounding properly for some reason.

Thanks for the help!
Jarred MeyerProduction ManagerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Gustav BrockConnect With a Mentor CIOCommented:
Yes, use the Round15 from this link which also performs a perfect 4/5 rounding:


Helen FeddemaConnect With a Mentor Commented:
Rounding in Access is more complicated than you might think.  See Access Archon #94 (a guest article by Geoff Shepherd) for lots of info on rounding.

HainKurtSr. System AnalystCommented:
dont use function, use it in sql... does it make any difference?

select Round16(v, 2) as rounded_value from mytable
select CDbl(Format$(v * 10 ^ 2, "0")) / 10 ^ 2 as rounded_value from mytable
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

aikimarkConnect With a Mentor Commented:

Why not use the Round17 code?
Gustav BrockCIOCommented:
Right, sorry, I didn't notice but did a copy and past from an old post.

btw...are you the gustav that contributed Round12 & Round15?  If so, thank you for your participation in that wonderful little repository of VB goodness/speediness.
Jarred MeyerProduction ManagerAuthor Commented:
Thanks all for your help! Sorry I'm just now getting back to this. Those seem to work better.
Gustav BrockCIOCommented:
You are welcome!

And yes, that Gustav is me.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.