473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

ROUND Worksheet function

Hi all,
i need help regarding one worksheet function: can we use ROUND worksheet function in access also, i need suggestions (how to use)
plz help me
Jul 30 '08 #1
5 1944
Stewart Ross
2,545 Expert Mod 2GB
Hi. Access VBA supplies Round as an intrinsic function, and you should be able to use it anywhere you can use an expression (in a query, in VBA code etc).

It's syntax is identical to its Excel counterpart:

Expand|Select|Wrap|Line Numbers
  1. someresult = round(numericvalue, decimalplaces)
In SQL its use is just

Expand|Select|Wrap|Line Numbers
  1. SELECT round([fieldname], [decimalplaces]) as calculatedfieldname 
  2. FROM sometable
Example: to round field Subtotal of table Test to two decimal places:

Expand|Select|Wrap|Line Numbers
  1. SELECT round([subtotal], 2) As roundedsub FROM test;
-Stewart
Jul 30 '08 #2
sorry i am unable to get it
here i am giving the code
can u suggest me how to do it:

SELECT [Payslip ].[EmployeeNo], [Payslip ].[Name of the Member], [Payslip ].[Bank Number], [Payslip ].[other arrears], [Payslip ].[Basic Pay], [Payslip ].[PFapplicable],
IIf([PFapplicable]="yes",([Basic Pay]*0.5)) AS DP, ---- ROUND THIS FIGURE
IIf([PFapplicable]="yes",(([Basic Pay]+[dp])*0.47)) AS DA, ---- ROUND THIS FIGURE
IIf([PFapplicable]="yes",(([basic pay]+[DP])*0.3)) AS HRA, ---- ROUND THIS FIGURE
IIf([PFapplicable]="yes",(([Basic Pay]+[dp]+[da]+[basic arrears]+[dp arrears]+[da arrears])*0.12)) AS PF, ---- ROUND THIS FIGURE
FROM [Payslip];
Aug 1 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
OK, taking just one of your IIFs as an example and rounding to two decimal places:

Expand|Select|Wrap|Line Numbers
  1. IIf([PFapplicable]="yes",Round(([Basic Pay]*0.5), 2)) AS DP
The others are done the same way.

Please note that rounding is generally done as the final step in data presentation - i.e. at the reporting stage (or on a form presented to a user). Rounding in a query would not normally be necessary unless the data is to be exported "raw" for use by users in some other application.

Rounding data too early can lead to the accumulation of small rounding errors in totals and so on if further calculations are carried out; it is normal to retain as many significant figures as possible for calculation purposes and to round the final result only.

If you are printing the data using a report you can always format the controls to present the number of decimal places required - the format selected will apply rounding to the value shown automatically.

-Stewart
Aug 1 '08 #4
I tried it in query but I am unable to see the report of it.
it showing some error
if i want to write the code in form or in report whats the process
sorry for the trouble i am giving u
i am learning access recently
plz provide me needed help
thank u
Aug 1 '08 #5
Stewart Ross
2,545 Expert Mod 2GB
Hi. To format a control on a form or a report to show a rounded value open the form or report in design view, select each control. If the control properties tab is not showing right click on the control, then select properties to display the properties tabs. Select the Format property and set to Fixed. Select decimal places and set to 2 (or 1 or 0 or whatever is the number of places you wish to display).

I'm sorry to say that I doubt if I will be able to assist you further with this issue, as there is no more I can do for you without having the database in front of me. I have done all I can to ensure that you understand that rounding is one of the last tasks undertaken, and that it is a presentation issue resolved by using fixed decimal places for your controls as mentioned above.

-Stewart
Aug 1 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jef Driesen | last post by:
I need to implement a function to implement the rounding of floating point values. At the moment i have two different implementations, depending on the type of the return value (integer or double)....
6
by: Penguin | last post by:
At some long ago time Steve Jorgensen answered thus: Subject: Re: How can I round a time? Newsgroups: comp.databases.ms-access Date: 1998/12/11 Access represents a date internally as a double...
2
by: Anne Sachleben via AccessMonster.com | last post by:
I am using the TransferSpreadsheet function to export a query result to a specific worksheet in an Excel file titled "report". I want the result to be exported to the worksheet titled "facts". ...
17
by: nomenklatura | last post by:
Hi, System.Math.Round function is confused me. for example i want to round 3.245 in with decimal symbol Result should be = 3.25 When i try to this in vb: A = 3.245 X = Round(A, 2) then...
1
by: madeleine.macphail | last post by:
All I'm currently attempting to move us from a spreadsheet based system to a database system. The first phase is to import the data on a regular basis from the spreadsheets to get the database...
3
by: sun919 via DotNetMonster.com | last post by:
hi , i have a question to ask regarding deleting the worksheet basically i have written code which find the select worksheet which work fine but it didn't delete the worksheet from the workbook...
22
by: DThreadgill | last post by:
Hi all - having a bit of problem with this code. It works in one of the databases that I have but not the one I'm currently working with...I've compared references and they're both the same: When...
5
kadghar
by: kadghar | last post by:
Most of the times VBA is used with variables. Objects (such as worksheets, cells or databases) are only used when we read their properties (value, formula, font...) or we use a method (save,...
1
by: Bonzs | last post by:
I have troule with this macro... geting the used rsnge... Public strName As String, ws As Worksheet Sub Test() Workbooks.Open Filename:= _ "C:\Documents and Settings\User\Desktop\IT...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.