I am trying to use the code below to add 30 days if Test 1 results and 40 days if Test 2 results. Nothing happens as of right now and I am not sure why. Thank you.
Code:
Order Date (user enters date)
Test (user selcts panel)
Order Date (user enters date)
Test (user selcts panel)
Select Case Me.Text45
Case "Test1"
Me.Text199 =
Public Function CountDays(OrderDate As Date, NoOfDays As Integer) As Date
' Function to count no of working days
Dim tmpNo As Integer
Dim tmpOrderDate As Date
Dim tmpStartDate As Date
Dim i As Integer
tmpNo = NoOfDays
tmpOrderDate = startDate
tmpDate = startDate
i = 0
Do Until i = NoOfDays
If Weekday(tmpDate) = 1 Or Weekday(tmpDate) = 7 Then
tmpNo = tmpNo + 1
ElseIf DCount("*","tblHoliday2014","dtmDate = #" & tmpDate & "#") > 0 Then
tmpNo = tmpNo + 1
Else
i = i + 1
End If
tmpDate = tmpDate + 1
Loop
CountDays = DateAdd("d", tmpNo, tmpOrderDate)
End Function
Select Case Me.Text45
Case "Test2"
Me.Text199 =
Public Function CountDays(startDate As Date, NoOfDays As Integer) As Date
' Function to count no of working days
Dim tmpNo As Integer
Dim tmpDate As Date
Dim tmpStartDate As Date
Dim i As Integer
tmpNo = NoOfDays
tmpStartDate = startDate
tmpDate = startDate
i = 0
Do Until i = NoOfDays
If Weekday(tmpDate) = 1 Or Weekday(tmpDate) = 7 Then
tmpNo = tmpNo + 1
ElseIf DCount("*","tblHoliday2014","dtmDate = #" & tmpDate & "#") > 0 Then
tmpNo = tmpNo + 1
Else
i = i + 1
End If
tmpDate = tmpDate + 1
Loop
CountDays = DateAdd("d", tmpNo, tmpStartDate)
End Function