How do I roundup a number in Access 2000

  • Thread starter Thread starter Guest
  • Start date Start date
Int() rounds a number down, so you can round up like this:
- negate the number
- divide by 150
- take the Int()
- multiply by 150
- negate the result.

Result: -150 * Int(-[YourFieldNameHere] / 150)
 
That works to roundup the original number but doesn't give me the number
divided by 150. it gives me some ideas though thanks
Paul

Allen Browne said:
Int() rounds a number down, so you can round up like this:
- negate the number
- divide by 150
- take the Int()
- multiply by 150
- negate the result.

Result: -150 * Int(-[YourFieldNameHere] / 150)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Paul LeBlanc said:
I am trying to get a query to roundup to the nearest whole number when
divided by 150
 
Int(-([SumOfqty])/150)*-1 was the final solution
thanks for the tip!
Paul

Paul LeBlanc said:
That works to roundup the original number but doesn't give me the number
divided by 150. it gives me some ideas though thanks
Paul

Allen Browne said:
Int() rounds a number down, so you can round up like this:
- negate the number
- divide by 150
- take the Int()
- multiply by 150
- negate the result.

Result: -150 * Int(-[YourFieldNameHere] / 150)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Paul LeBlanc said:
I am trying to get a query to roundup to the nearest whole number when
divided by 150
 
Paul said:
Int(-([SumOfqty])/150)*-1 was the final solution
thanks for the tip!
Paul

Depending on what you need, this might not work for negative numbers.

Another possibility might be

ROUNDUP([SumOfqty]/150, 0)


-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
Vincent Johns said:
Paul said:
Int(-([SumOfqty])/150)*-1 was the final solution thanks for the tip!
Paul

Depending on what you need, this might not work for negative numbers.

Another possibility might be

ROUNDUP([SumOfqty]/150, 0)

That might be a possibility if you've written a ROUNDUP function.

AFAIK, there's no ROUNDUP function built into Access.
 
Douglas said:
Paul LeBlanc wrote:

Int(-([SumOfqty])/150)*-1 was the final solution thanks for the tip!
Paul

Depending on what you need, this might not work for negative numbers.

Another possibility might be

ROUNDUP([SumOfqty]/150, 0)


That might be a possibility if you've written a ROUNDUP function.

AFAIK, there's no ROUNDUP function built into Access.

Sorry, that's correct; I was thinking of a worksheet function that
Access might invoke via Excel or a Microsoft Office Spreadsheet object
-- not practical in this case.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
Karl,
That rounds down or up depending on the fraction, I want it to always round
up.
Int(-([FieldName])/150)*-1 works as a simple solution
Paul

KARL DEWEY said:
Round([YourField]/150)

Paul LeBlanc said:
I am trying to get a query to roundup to the nearest whole number when
divided by 150
 
It probably didn't matter,
but just in case....

It looks like it would depend on
how you wanted to define "up"
for a negative number...

num = 3.6
?-Int(-num)
4
?Sgn(num)*(-Int(-Abs(num)))
4

num = -3.6
?-Int(-num)
-3
?Sgn(num)*(-Int(-Abs(num)))
-4


Sgn([SumOfqty])*(-Int(-Abs([SumOfqty])/150)))

At first I thought how could a sumofqty
be negative anyway, then I remembered
how at work, with understaffed emp and at
crunch times, we can get negative inventory
when the transfers-to-stores process
has not caught up with sales....

good luck.

gary

What, its *not* a perfect world?
 

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

Back
Top