Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Round in access 97 1

Status
Not open for further replies.

Geraldo

Programmer
Mar 18, 2002
37
0
0
PT
Access 2000 has the function round for round values, that function doesn´t exist in access 97, how can i round values in access 97.

Geraldo
 
Use the int function; for example:

x = 3.4
? Int(x + 0.5)

Will return 3

x = 3.5
? Int(x + 0.5)
Will return 4

The + 0.5 ensures 'rounding up' as opposed to truncating. Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Well it's a way to do it, the other is using excel round function like this.

dim ex as excel.application
dim nn as long
dim x as integer
x = 3
set ex = createobject("excel.application")
nn = ex.worksheetfunction.round(34567.65,x)
debug.print 34567.65 & nn
set ex = nothing

x represent the number off fractionary digits you want to use.
by that way can select how many fractionary digits you need to round.
 
An interesting approach, but possibly a bit of an overkill in this case given that it has to invoke an instance of Excel to do what is essentially a trivial operation.

Still your post provides a very good example of how easy it is to interface to Excel from Access, and utilise its function set. For this, I'm happy to give you a star. Cheers,

Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top