Trying to write a Do Loop for vacation time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tdumas
    New Member
    • Aug 2014
    • 1

    #1

    Trying to write a Do Loop for vacation time

    I am doing a database for vacation time. And we have special circumstances for new hires where they get vacation time but then have to wait until their anniversary date equals the time line to accumulate more vacation. This is the first part of the vacation coding.
    Code:
    If Me.cat.Value = 1 Then ' Fulltime
            lTime = DateDiff("yyyy", Me.annDate.Value, Now())
            
               Select Case lTime
                Case Is < 1
                    If ((monthIn = 1) Or (monthIn = 2)) And (DateDiff("d", Me.annDate.Value, Now) > 180) Then
                    Me.avHrs.Value = 32
                    ElseIf ((monthIn = 3) Or (monthIn = 4)) And (DateDiff("d", Me.annDate.Value, Now) > 150) Then
                    Me.avHrs.Value = 24
                    ElseIf ((monthIn = 5) Or (monthIn = 6)) And (DateDiff("d", Me.annDate.Value, Now) > 120) Then
                    Me.avHrs.Value = 16
                    ElseIf ((monthIn = 7) Or (monthIn = 8)) And (DateDiff("d", Me.annDate.Value, Now) > 90) Then
                    Me.avHrs.Value = 8
                    Else
                    Me.avHrs.Value = 0
                    End If
                Case Is = 1
                    Me.avHrs.Value = 40
                Case Is < 3
                    Me.avHrs.Value = 40
                Case Is < 6
                    Me.avHrs.Value = 80
                Case Is < 10
                    Me.avHrs.Value = 120
                Case Is < 13
                    Me.avHrs.Value = 128
                Case Is < 16
                    Me.avHrs.Value = 136
                Case Is < 19
                    Me.avHrs.Value = 144
                Case Is < 22
                    Me.avHrs.Value = 152
                Case Is > 22
                    Me.avHrs.Value = 160
            End Select
    Now I am stuck on the special cases. For example: I was hired and received 88 hours but I won't get any more vacation until my anniversary date falls into the greater than 5 years mark. So for the special cases we have a value that equals 4 (special) and then we enter their hours into the text box. Instead of the system figuring it out.
    So I am not sure how to write that programming.
    Last edited by Rabbit; Aug 13 '14, 04:26 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3665

    #2
    First, using DateDiff("yyyy" ) may cause problems as any time the dates are in different years, the result will be >= 1.

    For the special cases, unless there is a standard formula for determining what to enter for leave, those will have to be managed manually.

    Also, please use code tags when posting code.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      I would suggest that, if you want someone to help you code your logic for you, you should at least explain that logic fully in clear words that include explanations for all the variables currently in your code.

      If you do that well then you may get lucky. Typically we won't simply do your work for you, but many of our experts are willing to help where they can if only you give them the full question to work with.

      Comment

      Working...