D
deercreek
I have the following query and I am figuring a number to fill a text
box in a form. The code works but I cant get the text box to update
unless I change record stes and then come back.
I have the line Call GetCampDays is in 3 places.
1. The After Update event of the Start Date Control
2. The After Update event of the End Date Control
3. The Current event of the form
Anyone have any other thoughts? Thanks for help!!
Dim intTotalDays As Integer ' Counter for number of days
Dim dtmToday As Date ' To increment the date to compare
dtmEnd = DateAdd("d", -1, dtmEnd) 'don't count last day
therefore don't even look at it
intTotalDays = 0 'Startwith 0 days ' We have 0 days to
start
dtmToday = dtmStart
'InitiateCompare Date
Do Until dtmToday > dtmEnd
intTotalDays = intTotalDays + 1 ' Assum we will count
then take our weekend and Holiday
If Weekday(dtmToday, vbMonday) > 4 Then 'It is
Saturdayor Sunday
intTotalDays = intTotalDays - 1 'Take one
dayaway for weekend
ElseIf Not IsNull(DLookup("[Holidate]", "Holidays", _
"[Holidate] = #" & dtmToday & "#")) Then 'It is
aHoliday
intTotalDays = intTotalDays - 1 'Take one
dayaway for the Holiday
End If
dtmToday = DateAdd("d", 1, dtmToday) 'Add a day
forNext Compare
Loop
'Until dtmToday > dtmEnd
'All days havebeen compared
CalcWorkDays = intTotalDays 'Return the
Value
box in a form. The code works but I cant get the text box to update
unless I change record stes and then come back.
I have the line Call GetCampDays is in 3 places.
1. The After Update event of the Start Date Control
2. The After Update event of the End Date Control
3. The Current event of the form
Anyone have any other thoughts? Thanks for help!!
Dim intTotalDays As Integer ' Counter for number of days
Dim dtmToday As Date ' To increment the date to compare
dtmEnd = DateAdd("d", -1, dtmEnd) 'don't count last day
therefore don't even look at it
intTotalDays = 0 'Startwith 0 days ' We have 0 days to
start
dtmToday = dtmStart
'InitiateCompare Date
Do Until dtmToday > dtmEnd
intTotalDays = intTotalDays + 1 ' Assum we will count
then take our weekend and Holiday
If Weekday(dtmToday, vbMonday) > 4 Then 'It is
Saturdayor Sunday
intTotalDays = intTotalDays - 1 'Take one
dayaway for weekend
ElseIf Not IsNull(DLookup("[Holidate]", "Holidays", _
"[Holidate] = #" & dtmToday & "#")) Then 'It is
aHoliday
intTotalDays = intTotalDays - 1 'Take one
dayaway for the Holiday
End If
dtmToday = DateAdd("d", 1, dtmToday) 'Add a day
forNext Compare
Loop
'Until dtmToday > dtmEnd
'All days havebeen compared
CalcWorkDays = intTotalDays 'Return the
Value