In the beginning I thought I fully understood my problem and started to write some VBA code to solve it. (At best I'm a novice, but I'm trying to use VBA when possible to facilitate my learning.) At this juncture I've realized that the problem is a little different than I first understood it.... so I hope I haven't gone down a rabbit hole with this one.
I have a table, CalData, that has two fields CAL and EFF. CAL are work centers and EFF is a series of event date lists. It looks like the following.
CAL EFF
340100 5/1/16
340100 5/15/16
060100 6/1/16
060200 6/1/16
... etc..
Ultimately I'm trying to create a separate table (tblCal) that has a record for each work center and date (for 60 days starting from earliest date). I wrote some VBA, but was only able to loop through the 60 days for one work center. I wanted to get each work center, but I got stumped on how to proceed. I do appreciate the help!
<code>
Public Sub Ibetss()
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset
Dim dbv As DAO.Database
Set rs = CurrentDb.OpenRecordset("CalData")
Set dbv = CurrentDb
Set rst = dbv.OpenRecordset("tblcal")
Dim DD As Date
Dim D As Integer
Dim DE As Date
'Finds the minimum date
DD = DMin("Eff", "CalData")
'Loops the daily increment
For D = 1 To 60
DE = DateAdd("d", D, DD)
rst.AddNew
rst("Cal").Value = rs!Cal
rst("Eff").Value = DE
rst.Update
Next D
End Sub
</code>
I have a table, CalData, that has two fields CAL and EFF. CAL are work centers and EFF is a series of event date lists. It looks like the following.
CAL EFF
340100 5/1/16
340100 5/15/16
060100 6/1/16
060200 6/1/16
... etc..
Ultimately I'm trying to create a separate table (tblCal) that has a record for each work center and date (for 60 days starting from earliest date). I wrote some VBA, but was only able to loop through the 60 days for one work center. I wanted to get each work center, but I got stumped on how to proceed. I do appreciate the help!
<code>
Public Sub Ibetss()
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset
Dim dbv As DAO.Database
Set rs = CurrentDb.OpenRecordset("CalData")
Set dbv = CurrentDb
Set rst = dbv.OpenRecordset("tblcal")
Dim DD As Date
Dim D As Integer
Dim DE As Date
'Finds the minimum date
DD = DMin("Eff", "CalData")
'Loops the daily increment
For D = 1 To 60
DE = DateAdd("d", D, DD)
rst.AddNew
rst("Cal").Value = rs!Cal
rst("Eff").Value = DE
rst.Update
Next D
End Sub
</code>