By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,704 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,704 IT Pros & Developers. It's quick & easy.

Rounding up by a specific increment...?

P: n/a
I have a wall product that is made in 4' wide increments. The product
is sold by the foot. A customer may order 38 feet but they will
actually receive 4 sections for a total of 40 feet. (they would then
field cut it to fit....)

In order to provide a shipping quote, I have to calculate a weight.
The weight table for this item lists a weight per 4' section. So what
I was trying to do was divide the order qty by a UOM_factor which in
this case is 4 and then multiplying that times the 4' section weight.
This works but only if the ordered qty is actually in a multiple of 4.

i.e.
item weight per 4 ft: 10 lbs
order qty = 80 feet
uom_factor= 4
80 / uom_factor = 20
20 * 10lbs = 200lbs WORKS OK !

order qty = 77 feet
77 / uom_factor = 19.25
19.25 * 10 = 192.50lbs NO GOOD because even though they
only "ordered" 77 feet they would receive 80 feet.

How can I make it round "up" to the nearest increment of 4 in order to
capture the "true" shipping weight?

Thanks for any suggestions....

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I use the following function, which Arvin Meyer posted a long time ago in this
newsgroup. Note that I'm copying from a db I use, so I may have made minor
adjustments for my own application. But it should get you on the right track.

Beware of weird line wraps.

HTH.

Jan

Function Rnd2Num(Amt As Variant, RoundAmt As Variant, Direction As Integer) As
Double
'From: Arvin Meyer
'Newsgroups: comp.Databases.ms -Access
'Date: 1999/04/21
'Use it in your textbox's controlsource like:
'=Rnd2Num([Forms]![frmWhatever]![yearprice],1,1)
On Error Resume Next
Dim Temp As Double
Temp = Amt / RoundAmt
If Int(Temp) = Temp Then
Rnd2Num = Amt
Else
If Direction = rnddown Then
Temp = Int(Temp)
Else
Temp = Int(Temp) + 1
End If
Rnd2Num = Temp * RoundAmt
End If
End Function


How can I make it round "up" to the nearest increment of 4 in order to
capture the "true" shipping weight?

Jan Stempel
Stempel Consulting
Nov 12 '05 #2

P: n/a
Try

If OrderQty \ UOM_factor = OrderQty / UOM_factor then ' Integer
division = ordinary division
QtyToSend = OrderQty
Else
QtyToSend = (OrderQty \ UOM_factor + 1) / UOM_factor ' Round up to
nerest 4 feet
End If

Phil
<Sox Fan in CT> wrote in message
news:23******************************@news.teranew s.com...
I have a wall product that is made in 4' wide increments. The product
is sold by the foot. A customer may order 38 feet but they will
actually receive 4 sections for a total of 40 feet. (they would then
field cut it to fit....)

In order to provide a shipping quote, I have to calculate a weight.
The weight table for this item lists a weight per 4' section. So what
I was trying to do was divide the order qty by a UOM_factor which in
this case is 4 and then multiplying that times the 4' section weight.
This works but only if the ordered qty is actually in a multiple of 4.

i.e.
item weight per 4 ft: 10 lbs
order qty = 80 feet
uom_factor= 4
80 / uom_factor = 20
20 * 10lbs = 200lbs WORKS OK !

order qty = 77 feet
77 / uom_factor = 19.25
19.25 * 10 = 192.50lbs NO GOOD because even though they
only "ordered" 77 feet they would receive 80 feet.

How can I make it round "up" to the nearest increment of 4 in order to
capture the "true" shipping weight?

Thanks for any suggestions....

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.