Loading Calendar with query data |
Post Reply |
Author | |
tomgriff
Groupie Joined: 10 August 2006 Status: Offline Points: 25 |
Post Options
Thanks(0)
Posted: 15 March 2007 at 11:45am |
Hello,
I have a program written in vb6 with an Access mdb backend.
I need to load the calendar with the events for a specific Staff Member, or a specific Cleint, or a specific Project.
I have a screen where the client can select a staff member and I want the calendar to load only the events for that staff member.
I have looked throug the forum and I don't see topics that cover this, if I missed a topic that covers this I apologise.
|
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
Just load a recordset with the events that you want (or load a recordset with all of the events, you can filter out the unwanted ones later)
Then, loop through the recordset adding the events. Dim NewEvent As CalendarEvent Dim strCaption as String Set rsDays = New ADODB.Recordset With rsDays .Open sql, db, adOpenForwardOnly, adLockReadOnly Calendar.DataProvider.RemoveAllEvents Do While Not .EOF Set NewEvent = Calendar.DataProvider.CreateEvent If blnContinue = True Then strCaption = "Event Title" 'add any custom properties you may want NewEvent.CustomProperties.Property("RequestID") = CLng(!ID) NewEvent.CustomProperties.Property("Status") = Cstr(!Status) 'set up the other event properties we need NewEvent.StartTime = CDate(!StartDate) NewEvent.EndTime = DateAdd("d", 1, CDate(!EndDate)) NewEvent.AllDayEvent = True NewEvent.Label = strCaption NewEvent.Subject = strCaption NewEvent.Body = strBody 'add icons if you want NewEvent.CustomIcons.Add ID_VACATION 'set any theme properties you want to set (I am using Icons so I had to set these HeightFormula Properties) Calendar.Theme.MonthView.Event.HeightFormula.Divisor = 1 Calendar.Theme.MonthView.Event.HeightFormula.Multiplier = 0 Calendar.Theme.MonthView.Event.HeightFormula.Constant = 20 Calendar.Theme.DayView.Event.HeightFormula.Divisor = 1 Calendar.Theme.DayView.Event.HeightFormula.Multiplier = 0 Calendar.Theme.DayView.Event.HeightFormula.Constant = 20 Calendar.Theme.RefreshMetrics Calendar.DataProvider.AddEvent NewEvent End If .MoveNext Loop .Close 'populate the calendar Calendar.Populate End With Set rsDays = Nothing |
|
tomgriff
Groupie Joined: 10 August 2006 Status: Offline Points: 25 |
Post Options
Thanks(0)
|
Thank you very much for your quick response. I will give this a try.
|
|
tomgriff
Groupie Joined: 10 August 2006 Status: Offline Points: 25 |
Post Options
Thanks(0)
|
I have tried to get the above example to work for my needs, but it doesn't seem to do the trick. Let me explain a bit more what I need.
I need to load events from the event file for a specific Staff member, or a specific client, or a specific project depeding what section of my program is active. I do not have any data from the event in another table to copy into an event. When I use the removeall in the above example, my event table is cleared. I do not want to clear my event table.
How can I load specific items from the event table into the calendar without clearing the event table.
Is there any way to query the event table using a custom properties field, of if I have a list of the eventid's that I need to load.
|
|
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
You have to do 2 loops: the first one will delete only your specific items from the existing events collection; and the second one will add all specific items reloaded from your storage.
-- WBR, Serge |
|
jcbaena
Newbie Joined: 20 July 2006 Location: Spain Status: Offline Points: 19 |
Post Options
Thanks(0)
|
but...if you make a RemoveAllEvents...¿what do you load on second loop?
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |