Need some help updating text box after query in form.

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
 
B

BruceM

I would suggest that if you don't get a response in this thread that you try
a new thread with a subject something like:
Count Days, Ignore Weekends
Questions with generic subject lines may not get the same attention as those
with specific subjects.
The only thing I can suggest (before I leave the office for a few days) is
adding the line:
Me.Requery
at the end of the code. Don't know if that will work, but it's all I can
think of at the moment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top