Dave,
Well, something isn't right. After I copied and pasted the solution into a
module, some of my queries are not working any longer.
Before the data is ready for service date, I need to check the start date is
not before July 1, and the end date is not after Dec. 31.
I am using the DateSerial(y,m,d) function, but each time I run my query I
get a compile error on this formula. As long as I don't have the module in
the database, the query works fine. can you shed some light on this?
Also,
A couple of questions about the programming:
These beginning sections: They are just for reference to the tables, correct?
'TableA
'UserName
'FromDate
'ToDate
Here is the actual table name and structure I am using for TableA:
Databasebase Name: Quarterly Reports
Table name: SummaryofServiceDates
Fields:
Username
LastName
FirstName
DOB
BeginDate
EndDate
'TableB
'UserName
'ServiceDate
'DayCount
Dim rstUsers As Recordset
Dim rstService As Recordset
Dim lngDayCount As Long
Dim strCurrUser As String
Dim dtmServiceDate As Date
With CurrentDb - Should I change this name to [Quarterly Reports]
Set rstUsers = .OpenRecordset("TableA") - Should TableA be
represented as [Quarterly Reports].[SummaryofServiceDates]
Set rstService = .OpenRecordset("TableB")
End With
With rstUsers
.MoveLast
.MoveFirst
End With
Do While Not rstUsers.EOF
dtmServiceDate = rstUsers!FromDate
lngDayCount = 1
Do While dtmServiceDate <= rstUsers!ToDate
With rstService
.AddNew
!UserName = rsUsers!UserName
!ServiceDate = dtmServiceDate
!DayCount = lngDayCount
.Update
End With
dtmServiceDate = DateAdd("d", 1, dtmServiceDate)
lngDayCount = lngDayCount + 1
Loop
rstUsers.MoveNext
Loop
rstUsers.Close
rstService.Close
Set rstUsers = Nothing
Set rstService = Nothing
do I need to call this something? (like a function name, servicedates?)
I am not the greatest Module programmer. I can read it better than I can
write the code.
Thanks,
Mike
Klatuu said:
Even if the train rolls over and over into the station, hey, it got there
didn't it....
Yes, it did. <g>
Let me know how it goes.