Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Loading Calendar with query data
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Loading Calendar with query data

 Post Reply Post Reply
Author
Message
tomgriff View Drop Down
Groupie
Groupie
Avatar

Joined: 10 August 2006
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote tomgriff Quote  Post ReplyReply Direct Link To This Post Topic: Loading Calendar with query data
    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.
 
Back to Top
jcollier View Drop Down
Senior Member
Senior Member


Joined: 15 February 2006
Status: Offline
Points: 250
Post Options Post Options   Thanks (0) Thanks(0)   Quote jcollier Quote  Post ReplyReply Direct Link To This Post Posted: 15 March 2007 at 1:01pm
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
Back to Top
tomgriff View Drop Down
Groupie
Groupie
Avatar

Joined: 10 August 2006
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote tomgriff Quote  Post ReplyReply Direct Link To This Post Posted: 15 March 2007 at 1:03pm
Thank you very much for your quick response.  I will give this a try.
Back to Top
tomgriff View Drop Down
Groupie
Groupie
Avatar

Joined: 10 August 2006
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote tomgriff Quote  Post ReplyReply Direct Link To This Post Posted: 16 March 2007 at 11:09pm

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.
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 22 March 2007 at 6:20pm
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
Back to Top
jcbaena View Drop Down
Newbie
Newbie
Avatar

Joined: 20 July 2006
Location: Spain
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote jcbaena Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2008 at 12:39pm
but...if you make a RemoveAllEvents...¿what do you load on second loop?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.