I would like to write a routine which will allow me to take dated events (records) in a table which span accross a set time frame and in the cases where no event took place
Here you go.
Sub FillBlanks()
Dim rsEvents As Recordset
Dim EventDate As Date
Dim Fld1 As String
Dim Fld2 As String
Dim Fld3 As String
Dim SQL As String
Set rsEvents = CurrentDb.OpenRecordset("SELECT * FROM tblevents ORDER BY EventDate")
'Save the current date & info
EventDate = rsEvents("EventDate")
Fld1 = rsEvents("Field1")
Fld2 = rsEvents("Field2")
Fld3 = rsEvents("Field3")
rsEvents.MoveNext
On Error Resume Next
Do
' Loop through each blank date
Do While EventDate < rsEvents("EventDate") - 1 'for all dates up to, but not including the next date
EventDate = EventDate + 1 'advance date by 1 day
rsEvents.AddNew
rsEvents("EventDate") = EventDate
rsEvents("Field1") = Fld1
rsEvents("Field2") = Fld2
rsEvents("Field3") = Fld3
rsEvents.Update
Loop
' get new current date & info
EventDate = rsEvents("EventDate")
Fld1 = rsEvents("Field1")
Fld2 = rsEvents("Field2")
Fld3 = rsEvents("Field3")
rsEvents.MoveNext
' new records are placed on the end of the recordset,
' so if we hit on older date, we know it's a recent insert and quit
Loop Until rsEvents.EOF Or EventDate > rsEvents("EventDate")
End Sub