Print Page | Close Window

Loading Calendar with query data

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=6654
Printed Date: 07 October 2024 at 11:16am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Loading Calendar with query data
Posted By: tomgriff
Subject: Loading Calendar with query data
Date 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.
 



Replies:
Posted By: jcollier
Date 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


Posted By: tomgriff
Date Posted: 15 March 2007 at 1:03pm
Thank you very much for your quick response.  I will give this a try.


Posted By: tomgriff
Date 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.


Posted By: sserge
Date 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


Posted By: jcbaena
Date Posted: 24 February 2008 at 12:39pm
but...if you make a RemoveAllEvents...¿what do you load on second loop?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net