Results 1 to 4 of 4
  1. #1
    Csalge is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    31

    date calculations in a form field

    I'm using an unbound field that provides me with the maximum allowable work hours for employees. I have the following module that seems to work for an employee with a compressed work schedule having weekends and Mondays off. I have a table that contains a list of holidays and they're also excluded. I have figured out up until this point. However, if a holiday falls in his day off (Mondays) that employee has Monday and the next day off. Any suggestions on how id calculate that in here I was thinking with another criteria where if datestoexclude = 2 then incount - 2. not sure how to incorporate it though

    Public Function Workingcompressed(StartDate As Date, EndDate As Date) As Integer
    On Error GoTo Err_Workingcompressed
    Dim intCount As Integer
    Dim temp As Integer
    Dim strWhere As String
    If StartDate = EndDate Then
    Workingcompressed = 1
    Exit Function
    End If
    intCount = 1
    Do Until StartDate = EndDate
    Select Case Weekday(StartDate)
    Case Is = 1, 7, 2
    intCount = intCount


    Case Else
    intCount = intCount + 1
    End Select
    strWhere = "datetoexclude=#" & StartDate & "#"
    If DCount("datetoexclude", "datestoexclude", strWhere) > 0 Then
    intCount = intCount - 1
    End If
    StartDate = StartDate + 1
    Loop
    Workingcompressed = intCount
    exit_workingcompressed:
    Exit Function
    Err_Workingcompressed:
    MsgBox Err.Description
    Resume exit_workingcompressed
    End Function

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    How do you determine that employee regular day off hits holiday?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Csalge is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    31
    Quote Originally Posted by June7 View Post
    How do you determine that employee regular day off hits holiday?
    I have a table called daystoexclude if it maches a date within the range it wont be counted.


    If DCount("datetoexclude", "datestoexclude", strWhere) > 0 Then
    intCount = intCount - 1

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Then maybe:

    intCount = intCount - DCount("datetoexclude", "datestoexclude", strWhere)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. date/time field calculations
    By donnan33 in forum Queries
    Replies: 4
    Last Post: 01-13-2012, 11:58 AM
  2. Replies: 7
    Last Post: 09-12-2011, 12:03 PM
  3. Date Calculations
    By Polarbilly in forum Forms
    Replies: 2
    Last Post: 06-01-2011, 12:55 PM
  4. Date calculations
    By NOTLguy in forum Access
    Replies: 10
    Last Post: 10-09-2010, 06:41 AM
  5. set date field on form to date variable
    By laavista in forum Access
    Replies: 3
    Last Post: 06-28-2010, 03:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums