473,395 Members | 1,613 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,395 software developers and data experts.

OT Calculation

23
i've got a problem for calculating OT in the report for a small payroll system;
when an employee worked on a holiday he's qualified for double overtime. so i've got tblholidays and other related tables

i tried the follwing argument

If Not IsNull(DLookup("[Hol_id]", "tblHolidays", "[Hol_Date] = #" & WORK_DATE & "#")) Then
otpay = [OT_HRS] * [HR_RATE] * [DOT_RATE]
Else
otpay = [OT_HRS] * [HR_RATE] * [OT_RATE]
End If
End Sub

how can i put this in a custom function in access? help appreciated
Nov 30 '06 #1
14 2173
MMcCarthy
14,534 Expert Mod 8TB
You can put this code in a function in a module. However, the values in
[OT_HRS], [HR_RATE], [DOT_RATE] and [OT_RATE] which I assume are on a form will not be available to the function unless you pass them in as parameters.

e.g. Assuming [OT_HRS] has a data type of Integer, WORK_DATE has a date/time data type and the other are currancy. You could try something like the following:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Function getOTHours(otHrs As Integer, hrRate As Currancy, dotRate As Currancy, otRate As Currancy, workDate As Date) As Currancy
  3.  
  4.    If Not IsNull(DLookup("[Hol_id]", "tblHolidays", "[Hol_Date] = #" & workDate & "#")) Then
  5.       getOTHours =otHrs * hrRate * dotRate
  6.    Else
  7.       getOTHours = otHrs * hrRate * otRate
  8.    End If
  9.  
  10. End Function
  11.  
To call the function ...

Expand|Select|Wrap|Line Numbers
  1. Me.otPay = getOTHours([OT_HRS], [HR_RATE], [DOT_RATE], [OT_RATE], WORK_DATE)
  2.  
Dec 1 '06 #2
kaib
23
You can put this code in a function in a module. However, the values in
[OT_HRS], [HR_RATE], [DOT_RATE] and [OT_RATE] which I assume are on a form will not be available to the function unless you pass them in as parameters.

e.g. Assuming [OT_HRS] has a data type of Integer, WORK_DATE has a date/time data type and the other are currancy. You could try something like the following:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Function getOTHours(otHrs As Integer, hrRate As Currancy, dotRate As Currancy, otRate As Currancy, workDate As Date) As Currancy
  3.  
  4.    If Not IsNull(DLookup("[Hol_id]", "tblHolidays", "[Hol_Date] = #" & workDate & "#")) Then
  5.       getOTHours =otHrs * hrRate * dotRate
  6.    Else
  7.       getOTHours = otHrs * hrRate * otRate
  8.    End If
  9.  
  10. End Function
  11.  
To call the function ...

Expand|Select|Wrap|Line Numbers
  1. Me.otPay = getOTHours([OT_HRS], [HR_RATE], [DOT_RATE], [OT_RATE], WORK_DATE)
  2.  


it works but it seems there are some problems in fractions:

given below the output of the report:

Report for Worked Hrs / OT Hrs.

Employee No# 1 Per Hr. Rate [P] $2.90
OT Rate [P] $1.50 Double OT Rate [P] $2.00

Employee Name ALFORD

Worked Dates| Total Hrs.| Worked Hrs.| Regular Hrs. |OT Hrs.| Reg.Pay| OT Pay | Total


01/Nov/2006 | 13.00 | 12.03| 8.00| 4.03| $23.20| $23.20| $46.40

18/Nov/2006 | 15.00| 14.20| 8.00| 6.20| $23.20| $26.10| $49.30

01/nov/2006 is a holiday:
when i calculate
OT hrs=4.03
Hr.Rate=2.90
Double OT Rate=2

so OT pay=23.37
but report gives me 23.20

18/nov/2006 is a normal day:
when i calculate
OT hrs=6.20
Hr.Rate=2.90
Double OT Rate=1.50
so OT pay=26.97

but report gives me 26.10


this causes me confusion
in table rates are all currency and hrs are converted to decimal and those fields are integer

what could be the reason for this diff.
help
thanks
Dec 2 '06 #3
blyxx86
256 100+
it works but it seems there are some problems in fractions:

given below the output of the report:

Report for Worked Hrs / OT Hrs.

Employee No# 1 Per Hr. Rate [P] $2.90
OT Rate [P] $1.50 Double OT Rate [P] $2.00

Employee Name ALFORD

Worked Dates| Total Hrs.| Worked Hrs.| Regular Hrs. |OT Hrs.| Reg.Pay| OT Pay | Total


01/Nov/2006 | 13.00 | 12.03| 8.00| 4.03| $23.20| $23.20| $46.40

18/Nov/2006 | 15.00| 14.20| 8.00| 6.20| $23.20| $26.10| $49.30

01/nov/2006 is a holiday:
when i calculate
OT hrs=4.03
Hr.Rate=2.90
Double OT Rate=2

so OT pay=23.37
but report gives me 23.20

18/nov/2006 is a normal day:
when i calculate
OT hrs=6.20
Hr.Rate=2.90
Double OT Rate=1.50
so OT pay=26.97

but report gives me 26.10


this causes me confusion
in table rates are all currency and hrs are converted to decimal and those fields are integer

what could be the reason for this diff.
help
thanks
M$ taking the extra money into their pockets. Duh?

No, it is rounding the hours (possibly both ways, but example only shows 2 values being rounded down)

So instead of being 6.2 hours, it is only calculating 6. I don't know how to fix this error, but I would check decimal places of where the units are being used AS integer (seeing as an integer is a whole number [1,2,3, 0..] not [1.4,1.5...])
Dec 2 '06 #4
blyxx86
256 100+
M$ taking the extra money into their pockets. Duh?

No, it is rounding the hours (possibly both ways, but example only shows 2 values being rounded down)

So instead of being 6.2 hours, it is only calculating 6. I don't know how to fix this error, but I would check decimal places of where the units are being used AS integer (seeing as an integer is a whole number [1,2,3, 0..] not [1.4,1.5...])

Try instead of AS INTEGER using "AS Single".
Dec 2 '06 #5
blyxx86
256 100+
Try instead of AS INTEGER using "AS Single".
Ok, one last try here to tell you the right thing..

Try using AS Decimal if Single doesn't work. Byte, Integer and Long Integer do not store decimal values.

Single stores up to 7, Double up to 15, and Decimal to 28. Depends on what you need. Decimal may be less confusing because you know the number system 0-9.
Dec 2 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
Ok, one last try here to tell you the right thing..

Try using AS Decimal if Single doesn't work. Byte, Integer and Long Integer do not store decimal values.

Single stores up to 7, Double up to 15, and Decimal to 28. Depends on what you need. Decimal may be less confusing because you know the number system 0-9.
blyxx86 is right.

Using Single or Double should solve your problem.

Mary
Dec 2 '06 #7
blyxx86
256 100+
blyxx86 is right.

Using Single or Double should solve your problem.

Mary
:) See, I'm learning too Mary. :)

It feels good to be able to help others when I've been instructed by those who are truly great at Access.

I wouldn't be able to construct something like an overtime calculation sheet, but I'm getting there. :)
Dec 2 '06 #8
MMcCarthy
14,534 Expert Mod 8TB
:) See, I'm learning too Mary. :)

It feels good to be able to help others when I've been instructed by those who are truly great at Access.

I wouldn't be able to construct something like an overtime calculation sheet, but I'm getting there. :)
It's great to see someone who's learned something and wants to impart it to others.

Keep up the good work.

Mary
Dec 3 '06 #9
kaib
23
It's great to see someone who's learned something and wants to impart it to others.

Keep up the good work.

Mary
yes thnks folks single works
let me ask u when i view table in datasheet view and click on work_hrs value it displays 12.93333 and when focus goes it's back to 12.93
in the design view work_hrs filed property is set as follows:

field size: Single
Format : Fixed
Decimal : 2

this is one the field there are 2-3 fieds are set like this
but in data sheet view if the figure is 12.90 eventhough u click it doesn't change if focus goes

these are some basic which i lack
so confused
thanks for ur efforts
Dec 3 '06 #10
blyxx86
256 100+
yes thnks folks single works
let me ask u when i view table in datasheet view and click on work_hrs value it displays 12.93333 and when focus goes it's back to 12.93
in the design view work_hrs filed property is set as follows:

field size: Single
Format : Fixed
Decimal : 2

this is one the field there are 2-3 fieds are set like this
but in data sheet view if the figure is 12.90 eventhough u click it doesn't change if focus goes

these are some basic which i lack
so confused
thanks for ur efforts
"Fixed" actually will display the numbers as regular numbers. example ____.##

it will only display the decimals to the hundredths. press F1 while in the "Format" in design mode for an explanation on the control. Then press "Number and Currency Data Types." it will explain the different values and also how to format you own. :)

Sometimes the help is confusing as heck, but other times it can
Dec 3 '06 #11
kaib
23
ok but how can get a running total of each emloyee code on the report
Dec 3 '06 #12
kaib
23
ok but how can get a running total of each emloyee code on the report
ok i got it by changing the 'running sum' property' to 'over group' and it gives the cumulative figure

in report i want to print details for only one employee (one employee code) on one page and if its different code it should print on another page
is it possible!
help appreciated
Dec 5 '06 #13
kaib
23
ok but how can get a running total of each emloyee code on the report
ok i got it by changing the 'running sum' property' to 'over group' and it gives the cumulative figure
Dec 5 '06 #14
MMcCarthy
14,534 Expert Mod 8TB
ok i got it by changing the 'running sum' property' to 'over group' and it gives the cumulative figure

in report i want to print details for only one employee (one employee code) on one page and if its different code it should print on another page
is it possible!
help appreciated
You will need a group for employee code and in the group header properties set 'Force New Page' to after section.

Mary
Dec 5 '06 #15

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

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
1
by: cdelaney | last post by:
I have a form that I created a calculation on using 2003. The calculation works exactly like I want it to but ONLY on the first and last record. The calculation does not work/exist on records in...
0
by: gavo | last post by:
Hi. using A2K; i have a form containing a continous subform. The question is, how can i call a calculation for one of the fields in the continous subform from the main form. At the moment i...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
5
by: =?Utf-8?B?amVsbGU3OQ==?= | last post by:
Hi, I want to use a difficult Excelsheet as source for my calculation in a ASP.NET (C#) page. I have 5 input fields on my ASP.NET page and when I press the submit button I want to put these...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.