Always round up in a query?

  • Thread starter Thread starter Mike Green
  • Start date Start date
M

Mike Green

Hi all
I have come across this little requirement for a database that I am writting
and I hope that someone could give me the answer?
I have a qury providing a calculation, but I need the answer to always round
up to the next whole number.
the query is quite simple TdArea * TdRequirement = FdQty but if the area is
7m and the required is 0.6 then when I get 4.2 I need the FdQty to round up
to 5.
Any pointers will be greatly appreciated.

Thanks

Mike
 
Dangerous since if the value is an integer you will add 1 to it.

A modification that will work is the following

- Int(-[FieldName])

This will always round up POSITIVE numbers and it will handle numbers
that are already integers.

You can also use

IIF(Int([FieldName])=[Fieldname], [FieldName],Int([FeildName])+1)

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
Mike Green said:
Hi all
I have come across this little requirement for a database that I am
writting and I hope that someone could give me the answer?
I have a qury providing a calculation, but I need the answer to always
round up to the next whole number.
the query is quite simple TdArea * TdRequirement = FdQty but if the area
is 7m and the required is 0.6 then when I get 4.2 I need the FdQty to
round up to 5.
Any pointers will be greatly appreciated.

=IIf([Number] <> Int([Number], Int([Number]) +1, [Number])

Tom Lake
 
I totaly forgot about rounded numbers, thanks for the note.

--
Good Luck
BS"D


John Spencer said:
Dangerous since if the value is an integer you will add 1 to it.

A modification that will work is the following

- Int(-[FieldName])

This will always round up POSITIVE numbers and it will handle numbers
that are already integers.

You can also use

IIF(Int([FieldName])=[Fieldname], [FieldName],Int([FeildName])+1)

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================


Ofer said:
The function Int will always round the number down, so add 1 to it

Int([FieldName]) + 1
 
Back
Top