rounding up in access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a value that is less than 0 in a query and would like it to round up
to 1.

Please advise and thank you in advance.
 
Use a function such as (aircode):

Public Function NoZero(varIn As Variant) As Variant
On Error Resume Next

If IsNumeric(varIn) Then
If varIn <=0 Then
varIn = 1
End If
Else
varIn = Null
End If

End Function

put that in a standard module and call it in a query like:

NewValue: NoZero([Original FieldName])
 
Maury

-2437 is less than 1 ... do you want to round to +1?

If you have "a value that is less than 0", why do you want a +1?

What are you working with (a bit more context might help folks offer
suggestions)?

Have you looked into using the IIF() function?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Sorry i'm just a basic user what i meant to say is that I have a value that
is less than 1 i.e 0.24 for instance and I want to round it up to +1.
 
Wayne

If you format that value to display as an integer, I suspect it will show
0.24 as 1.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
To round UP to the nearest WHOLE number I use the following expression:

-Int(-YourValue)

Example:

-Int(-0.24) = 1

I actually have a User Defined Function named Ceiling() {since that is the
name of similar functions in other systems} ...

Public Function Ceiling(dblValue As Double) As Currency
Ceiling = -Int(-dblValue)
End Function

Note ... the reason I use Currency as the return datatype is to get a larger
range of return numbers ... but you can use what seem appropriate (Long,
Integer, Byte).

HTH ...
 
DATADREALINE

Your a god spot on TY!!!

datAdrenaline said:
ToroundUPto the nearest WHOLE number I use the following expression:


-Int(-0.24) = 1
I actually have a User Defined Function named Ceiling() {since that is the
name of similar functions in other systems} ...
Public Function Ceiling(dblValue As Double) As Currency
Ceiling = -Int(-dblValue)
End Function
Note ... the reason I use Currency as the return datatype is to get a larger
range of return numbers ... but you can use what seem appropriate (Long,
Integer, Byte).

I followed your instructions, but for some reason it will just round
down with the INT function....for instance I'm calculating time units
in 15 minute intervals which means that 45 minutes would be 3 but
trying to get 46 minutes to equal 4....is there another function I
should use? Thanks.
 
I followed your instructions, but for some reason it will just round
down with the INT function....for instance I'm calculating time units
in 15 minute intervals which means that 45 minutes would be 3 but
trying to get 46 minutes to equal 4....is there another function I
should use? Thanks.

What's the actual code you're using? You must have altered Brent's code,
since it would convert any amount of minutes to 1 hour.
 

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

rounding dependent on value 2
Round up number 2
Rounding up! 2
Bankers Rounding 1
Rounding up or down in Access 2003 2
News CES 2019 round up 6
Found a Bug or Error in Access 2002-2003 Round Function 3
Rounding Values 2

Back
Top