round up to the next 1/2 kg....formatting

F

fishqqq

I have a field that updates the chargeable weight of shipments and
this field returns a number with 5 decimal places

The formula works perfectly except i need to round the weight up to
the next 1/2kg

ie:
325.24591 should be rounded to read 325.5
325.61111 should be rounded to read 326.0

currently the control source of the field is set as follows:

=IIf([text149]>[text151],[text149],[text151])

and what it is doing is comparing the actual weight of something to
it's volume weight and displaying the higher of the two. What i need
now is for the higher of the two to be rounded to the next 1/2kg as
shown above.

Can anyone recommend how to do this?

thanks
Steve
 
J

John W. Vinson

I have a field that updates the chargeable weight of shipments and
this field returns a number with 5 decimal places

The formula works perfectly except i need to round the weight up to
the next 1/2kg

ie:
325.24591 should be rounded to read 325.5
325.61111 should be rounded to read 326.0

currently the control source of the field is set as follows:

=IIf([text149]>[text151],[text149],[text151])

and what it is doing is comparing the actual weight of something to
it's volume weight and displaying the higher of the two. What i need
now is for the higher of the two to be rounded to the next 1/2kg as
shown above.

Can anyone recommend how to do this?

thanks
Steve

You can use the fact that the Int() function always rounds down - so by making
the number NEGATIVE, it will round away from zero. Multiply the value by -2 to
get it in half-kilogram steps, round, and then divide by two:

=-Int(-2*IIf([text149]>[text151],[text149],[text151]))/2
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
F

fishqqq

I have a field that updates the chargeable weight of shipments and
this field returns a number with 5 decimal places
The formula works perfectly except i need to round the weight up to
the next 1/2kg
ie:
325.24591 should be rounded to read 325.5
325.61111 should be rounded to read 326.0
currently the control source of the field is set as follows:
=IIf([text149]>[text151],[text149],[text151])

and what it is doing is comparing the actual weight of something to
it's volume weight and displaying the higher of the two. What i need
now is for the higher of the two to be rounded to the next 1/2kg as
shown above.
Can anyone recommend how to do this?
thanks
Steve

You can use the fact that the Int() function always rounds down - so by making
the number NEGATIVE, it will round away from zero. Multiply the value by -2 to
get it in half-kilogram steps, round, and then divide by two:

=-Int(-2*IIf([text149]>[text151],[text149],[text151]))/2
--

             John W. Vinson [MVP]
 Microsoft's replacements for these newsgroups:
 http://social.msdn.microsoft.com/Forums/en-US/accessdev/
 http://social.answers.microsoft.com/Forums/en-US/addbuz/
 and see alsohttp://www.utteraccess.com

that works great, thanks John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top