Always round up in a query?

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
 
G

Guest

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

Int([FieldName]) + 1
 
J

John Spencer

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
'====================================================
 
T

Tom Lake

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
 
G

Guest

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
 

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

Top