prettykittyq
asked on
Add records with empty dates to calendar
The problem is to insert “empty dates” in a table containing information about The Boss’s calendar.
The table is called CleanCalendar. It has the following fields:
StartDate (date/time)
Subject (text)
StartTime (date/time)
Location (text)
EndTime (date/time)
Description (text)
The Boss likes to have a space on his hard copy calendar for every day for the next six months, whether a given day has an appointment or not.
The appointments are being pulled in from his Outlook Calendar but Outlook only creates a record if there’s an appointment on that day, so I need to fill in the “empty dates.”
If I were writing pseudo code for this it would look like:
For MyDay = Today to Today’s Month Plus 6
Find Record where StartDate = MyDay
If Not Found, Insert Record Where StartDate = MyDay
Next MyDay
Can I do this somehow in Access?
The table is called CleanCalendar. It has the following fields:
StartDate (date/time)
Subject (text)
StartTime (date/time)
Location (text)
EndTime (date/time)
Description (text)
The Boss likes to have a space on his hard copy calendar for every day for the next six months, whether a given day has an appointment or not.
The appointments are being pulled in from his Outlook Calendar but Outlook only creates a record if there’s an appointment on that day, so I need to fill in the “empty dates.”
If I were writing pseudo code for this it would look like:
For MyDay = Today to Today’s Month Plus 6
Find Record where StartDate = MyDay
If Not Found, Insert Record Where StartDate = MyDay
Next MyDay
Can I do this somehow in Access?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Forgot:
In the report, create a header for each day to group appts for the day, or set the "HideDuplicates" to true to avoid printing duplicate dates.
In the report, create a header for each day to group appts for the day, or set the "HideDuplicates" to true to avoid printing duplicate dates.
Oops, shanesuebsahakarn read the question better than me :)
ASKER
Shane!
Worked first time out. Thanks so much.
Kitty
Worked first time out. Thanks so much.
Kitty
ASKER
ooops...except for the tiny typo in the first DIM statement...needs to be MyDay not MyDate to match the rest of the code
But I caught that all by myself. :-)
But I caught that all by myself. :-)
You can fill this table thus:
Sub FillCalendar(pintYear as Integer)
Dim datCurrent as Date
Dim datStop as Date
With CurrentDb
.Execute "DELETE * FROM zstblCalendar"
datCurrent = DateSerial(pintYear, 1, 1)
datStop = DateSerial(pintYear+1, 1, 1)
Do Until datCurrent = datStop
.Execute "INSERT INTO zstblCalendar (datDate) VALUES(" & CLng(datCurrent) & ")"
datCurrent = datCurrent+1
Loop
End With
End Sub
(code not tested)
Then create a report based on a join query (zstblCalendar LEFT JOIN CleanCalendar) which will produce at least one record per day and Null fields for days without any appointment.
Another solution would be to create a report based on your table, and using the Me.MoveLayout and Me.NextRecord, along with hiding fields etc. This way, you could force the report to produce one line for each day, printing the information in non-hidden fields.
Cool programming perhaps, but neither efficient nor easy to maintain.