Round down to nearest thousand

  • Thread starter Thread starter Emmy
  • Start date Start date
E

Emmy

Hello,

I need to update a field DOWN to the nearest thousand.

Ex) 147800 needs to be 147000

Does anyone know how to do this?

Thanks so much!

Emmy
 
Here is a function that rounds a number passed to it to
the place passed to it. Positive values in intplace round
decimal places and negative numbers round 10/100 etc

Function dblRound(dblRoundnum As Double, intPlaces As
Integer) As Double
Dim lngmultiplier As Long
If intPlaces >= 0 Then
lngmultiplier = 10 ^ intPlaces
dblRound = CLng(dblRoundnum * lngmultiplier) /
lngmultiplier
Else
lngmultiplier = 10 ^ Abs(intPlaces)
dblRound = CLng(dblRoundnum / lngmultiplier) *
lngmultiplier
End If
End Function

Example: dblRound(49192.96758, 3) = 49192.968
dblRound(49192.96758, -3) = 49000

you can pass it any numeric variable to round, but it will
give a type mismatch error if either parameter is alpha

DJ Walker

Network Programmer
(e-mail address removed)
314-781-0900 ext 790

St Louis Zoo
Visit www.stlzoo.org <http://www.stlzoo.org>
The Saint Louis Zoo is accredited by the American Zoo and
Aquarium Association (AZA). Look for the logo whenever you
visit a zoo or aquarium as your assurance that you are
supporting a facility dedicated to providing excellent
care for animals, a great experience for you, and a better
future for all living things. With its more than 200
accredited members, AZA is a leader in global wildlife
conservation, and your link to helping animals in their
native habitats.


-----Original Message-----
Emmy,

Try it like this...
([YourField]\1000)*1000

--
Steve Schapel, Microsoft Access MVP

Hello,

I need to update a field DOWN to the nearest thousand.

Ex) 147800 needs to be 147000

Does anyone know how to do this?

Thanks so much!

Emmy
.
 
This works, but it rounds up. I need it to round down.

Ex) 23700 now rounds to 24000. It needs to be 23000.

Thanks!
Emmy
-----Original Message-----
Hello,

I need to update a field DOWN to the nearest thousand.

Ex) 147800 needs to be 147000

Does anyone know how to do this?

1000 * ([fieldname] \ 1000)



.
 
1000 * Int([fieldname] / 1000)

--

Ken Snell
<MS ACCESS MVP>

This works, but it rounds up. I need it to round down.

Ex) 23700 now rounds to 24000. It needs to be 23000.

Thanks!
Emmy
-----Original Message-----
Hello,

I need to update a field DOWN to the nearest thousand.

Ex) 147800 needs to be 147000

Does anyone know how to do this?

1000 * ([fieldname] \ 1000)



.
 
Emmy,

Did you try it? This is the same as the suggestion I made, and it is
correct. John's formula applied to 23700 returns 23000. Please have
another go.
 
Back
Top