A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Timesheet formula



 
 
Thread Tools Display Modes
  #1  
Old September 18th, 2009, 02:59 AM posted to microsoft.public.access.forms
Jose Anibal
external usenet poster
 
Posts: 1
Default Timesheet formula

Hi
I have a form (Access 2007) where I enter weekly hours (present and absent)
for 60 employees. Every employee accumulates up to but not more than 480
hours at any moment during his employment period, (accumulates 12 hours every
month). If his balance is 480 sick live hours and gets absent, lets say, 32
hours during this week, then his sick leave balance should be 460 hours
([480-32]+[12] at the end of the month. If the employee is never absent, then
his sick leave balance should be no more than 480 hours. If he is absent 8
hours this week, then his balance should be 480 [480-8]+[12].
How can this be done in the form? What formula can I place in the query
to obtain the same information as above? Any help will be greatly
appreciated. Thanks in advance.

--
josean
  #2  
Old September 18th, 2009, 06:16 PM posted to microsoft.public.access.forms
Kipp Woodard
external usenet poster
 
Posts: 50
Default Timesheet formula

You might be able to use one or both of the following formulas.

Usage would be like:

[LeaveBalance] = MinOf(480, ([LeaveBalance] - [SickTaken]) +
[AccumulatedLeave])

Code Start
==================
Public Function MinOf(Value1 As Variant, Value2 As Variant) As Variant
Const PROC_NAME As String = "MinOf"

On Error GoTo ErrorHandler

If Value1 Value2 Then
MinOf = Value1
Else
MinOf = Value2
End If

Cleanup:
Exit Function

ErrorHandler:
MsgBox "Error: " & Err.Number & ", " & Err.Description, , MOD_NAME & "."
& PROC_NAME

On Error Resume Next

GoTo Cleanup

End Function


Public Function MaxOf(Value1 As Variant, Value2 As Variant) As Variant
Const PROC_NAME As String = "MaxOf"

On Error GoTo ErrorHandler

If Value1 Value2 Then
MaxOf = Value1
Else
MaxOf = Value2
End If

Cleanup:
Exit Function

ErrorHandler:
MsgBox "Error: " & Err.Number & ", " & Err.Description, , MOD_NAME & "."
& PROC_NAME

On Error Resume Next

GoTo Cleanup

End Function

==================
Code End


"Jose Anibal" wrote:

Hi
I have a form (Access 2007) where I enter weekly hours (present and absent)
for 60 employees. Every employee accumulates up to but not more than 480
hours at any moment during his employment period, (accumulates 12 hours every
month). If his balance is 480 sick live hours and gets absent, lets say, 32
hours during this week, then his sick leave balance should be 460 hours
([480-32]+[12] at the end of the month. If the employee is never absent, then
his sick leave balance should be no more than 480 hours. If he is absent 8
hours this week, then his balance should be 480 [480-8]+[12].
How can this be done in the form? What formula can I place in the query
to obtain the same information as above? Any help will be greatly
appreciated. Thanks in advance.

--
josean

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.