views:

34

answers:

1

On a report I have the following code

=Sum([PartQty]*[ModuleQty])

Example results are 2.1 or 2.6, what I need is for the valule to round up to read 3

+1  A: 

you could do

=Int(Sum([PartQty]*[ModuleQty]))+1

I think. That would get the Int part of the sum (2) and then add 1. you might need to be a little more clever as this will probably give you 3 even if the sum is exactly 2, which is probably not what you want.

not tested it but something along these lines might work (access syntax is not that great, but should give you the right idea) :

Iif(Sum([PartQty]*[ModuleQty])-Int(Sum([PartQty]*[ModuleQty]))=0,
     Sum([PartQty]*[ModuleQty]),
     Int(Sum([PartQty]*[ModuleQty]))+1)
Sam Holder
Hi Sam.You are right about your first idea, if the value is 2 it will round up to 3.Will try the next idea soon.Cheers
Shaun
Hi Sam.I have tried the new code, I keep getting an error message regarding the comma's.Shaun.
Shaun
Hi SamI have replaced the first comma with Then and the second comma with = still not working getting errors
Shaun
http://www.techonthenet.com/access/functions/advanced/iif.phpmight help with the syntax...this: http://www.databasedev.co.uk/count_values_countiif.html implies that you can use it in a report. try breaking it down to see if you can get the syntax correct:IIf(2-1=0,2,1+1) should be correct syntax from what I can see. and make sure you are using IIF and not IF
Sam Holder
Cheers, the code has been corrected.
Shaun