Hello,
I am having trouble achiving my end result.
I have a form (single) with a subform (cont.) and would like to be able to cpount the number of wokdays beteewn now() and a date that is in the table (or in the form, same one)...this is the code I am trying, but it returns 0
right now i have put this in the click event of a button to test it.
what am i doing wrong?
I know there are many examples of code in this forum, but it always gives me errors, and not being a VBA gouru, i have great difficulty fixing it...maybe i don't implement it right, I'm not 100% sure..
Any help, would be appriciated.
Thanks in adavanced,
Thanks,
Sylvain
I am having trouble achiving my end result.
I have a form (single) with a subform (cont.) and would like to be able to cpount the number of wokdays beteewn now() and a date that is in the table (or in the form, same one)...this is the code I am trying, but it returns 0
Code:
On Error GoTo Err_WorkingDays
Dim intCount As Integer
StartDate = StartDate + 1
'If you want to count the day of StartDate as the 1st day
'Comment out the line above
intCount = 0
Do While StartDate <= EndDate
'Make the above < and not <= to not count the EndDate
Select Case Weekday(StartDate)
Case Is = 1, 7
intCount = intCount
Case Is = 2, 3, 4, 5, 6
intCount = intCount + 1
End Select
StartDate = StartDate + 1
Loop
WorkingDays = intCount
Exit_WorkingDays:
Exit Function
Err_WorkingDays:
Select Case Err
Case Else
MsgBox Err.Description
Resume Exit_WorkingDays
End Select
End Function
right now i have put this in the click event of a button to test it.
Code:
Me.WeekDays = intCount
what am i doing wrong?
I know there are many examples of code in this forum, but it always gives me errors, and not being a VBA gouru, i have great difficulty fixing it...maybe i don't implement it right, I'm not 100% sure..
Any help, would be appriciated.
Thanks in adavanced,
Thanks,
Sylvain