Hello everyone -
I have created a form on Access 2003 that has 4 fields:
Date Completed Info Received
Date Projection sent to HR
Total Business Days (which is a calculation of the difference between the last 2 fields using "=calcWorkDays([Date Completed Info Received],[Date Projection sent to HR])"
SLA met? (which looks at the previous text box using "=IIf([Text168]<=4,"Yes",IIf([Text168]>=5,"No"))"
=calcWorkDays is in a module
Public Function calcWorkDays(dteStart As Date, dteEnd As Date) As Long
Dim i As Long 'day counter
Dim dteCurDay As Date
'set i = 1 if you want the first date to count as a full day
'or i = 0 if you do not want the first day to count as a full day
i = 1
dteCurDay = dteStart
Do Until dteCurDay >= dteEnd
'check date against holiday table
If 0 = DCount("[HolidayDate]", "tblHolidays", "[HolidayDate] = #" & dteCurDay & "#") Then
'continue checking for weekdays i.e. i increases only if week day value is not 1(Sunday) and not 7(Saturday)
If Weekday(dteCurDay) <> 1 And _
Weekday(dteCurDay) <> 7 Then
i = i + 1
End If
End If
dteCurDay = DateAdd("d", 1, dteCurDay)
Loop
calcWorkDays = i
'based on Calculating Networkdays
End Function
OK now the problem. When I insert dates into Date Request received from HR & Date Projection sent to HR it works perfectly fine, but when I open a new record I get a "#Error" in fields "Total Business Days" & "SLA met?". Is there any way I can hide or prevent this from showing? (keep in mind this is previous to entering the dates)
Thanks in advance
,
Jon
(I have another question but will wait until this is answered)
Edit: clarification!
I have created a form on Access 2003 that has 4 fields:
Date Completed Info Received
Date Projection sent to HR
Total Business Days (which is a calculation of the difference between the last 2 fields using "=calcWorkDays([Date Completed Info Received],[Date Projection sent to HR])"
SLA met? (which looks at the previous text box using "=IIf([Text168]<=4,"Yes",IIf([Text168]>=5,"No"))"
=calcWorkDays is in a module
Public Function calcWorkDays(dteStart As Date, dteEnd As Date) As Long
Dim i As Long 'day counter
Dim dteCurDay As Date
'set i = 1 if you want the first date to count as a full day
'or i = 0 if you do not want the first day to count as a full day
i = 1
dteCurDay = dteStart
Do Until dteCurDay >= dteEnd
'check date against holiday table
If 0 = DCount("[HolidayDate]", "tblHolidays", "[HolidayDate] = #" & dteCurDay & "#") Then
'continue checking for weekdays i.e. i increases only if week day value is not 1(Sunday) and not 7(Saturday)
If Weekday(dteCurDay) <> 1 And _
Weekday(dteCurDay) <> 7 Then
i = i + 1
End If
End If
dteCurDay = DateAdd("d", 1, dteCurDay)
Loop
calcWorkDays = i
'based on Calculating Networkdays
End Function
OK now the problem. When I insert dates into Date Request received from HR & Date Projection sent to HR it works perfectly fine, but when I open a new record I get a "#Error" in fields "Total Business Days" & "SLA met?". Is there any way I can hide or prevent this from showing? (keep in mind this is previous to entering the dates)
Thanks in advance

Jon
(I have another question but will wait until this is answered)
Edit: clarification!
Last edited: