Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Load multiple resources and events
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Load multiple resources and events

 Post Reply Post Reply
Author
Message
Rod001 View Drop Down
Newbie
Newbie


Joined: 29 September 2006
Location: United States
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rod001 Quote  Post ReplyReply Direct Link To This Post Topic: Load multiple resources and events
    Posted: 29 September 2006 at 11:56am
Hi,
 
I'm new to this control, and I'm trying to test and understand the MultipleResources and date events. I'm able to set up the calendar with multiple resources but not able to add any date events.

  Private Sub Form_Load()
    Init
    
    BuildResourceItems "john,tim,rod,bill,nancy"
 
  End Sub
 
Public Sub BuildResourceItems(sNames As String)
Dim arResources As New CalendarResources
Dim pRes0 As New CalendarResource
Dim pRes1 As New CalendarResource
Dim NewEvent As CalendarEvent
Dim pSchedules As CalendarSchedules
Dim strConnectionString As String
Dim sArray() As String
Dim ldx As Integer
  
strConnectionString = "Provider=Custom;Data Source="
pRes0.SetDataProvider2 strConnectionString, True
If pRes0.DataProvider Is Nothing Then
    Debug.Assert False
    Exit Sub
End If
If Not pRes0.DataProvider.Open Then
    If Not pRes0.DataProvider.Create Then
         Debug.Assert False
         Exit Sub
    End If
End If
 '// ** schedules
 
 Set pSchedules = pRes0.DataProvider.Schedules
 sArray = Split(sNames, ",")
 For ldx = 0 To UBound(sArray)
    pSchedules.AddNewSchedule sArray(ldx)
  
 Next
 pRes0.DataProvider.Save
 
 
 pRes1.SetDataProvider pRes0.DataProvider, False
 
 pRes0.Name = pSchedules.Item(0).Name
 pRes0.ScheduleIDs.Add pSchedules.Item(0).Id
 
 
 sArray = Split(sNames, ",")
 For ldx = 0 To UBound(sArray)
    Set pRes1 = New CalendarResource
    pRes1.Name = sArray(ldx)
    pRes1.ScheduleIDs.Add ldx
    arResources.Add pRes1
  
 Next
 CalendarControl1.SetMultipleResources arResources
 
   Set NewEvent = CalendarControl1.DataProvider.CreateEvent ' error problem occurs here

   NewEvent.StartTime = Now
    NewEvent.EndTime = Now
    NewEvent.Subject = "Product Meeting"
    NewEvent.ScheduleID = 1
    CalendarControl1.DataProvider.AddEvent NewEvent
 CalendarControl1.Populate
End Sub
 
Thank you,
Rod001
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: 03 October 2006 at 10:44am
Hi,

You just mixed up some things a little, and as result - no data provider is attached to Calendar at all.
 
I mean that you create data provider in pRes0 but skip a step of adding pRes0 to an array.
Also you have to set data provider to each resource.
 

Public Sub BuildResourceItems(sNames As String)
    Dim arResources As New CalendarResources
    Dim pRes0 As New CalendarResource
    Dim pRes1 As New CalendarResource
    Dim NewEvent As CalendarEvent
    Dim pSchedules As CalendarSchedules
    Dim strConnectionString As String
    Dim sArray() As String
    Dim ldx As Integer
  
    strConnectionString = "Provider=Custom;Data Source="
    pRes0.SetDataProvider2 strConnectionString, True
    If pRes0.DataProvider Is Nothing Then
        Debug.Assert False
        Exit Sub
    End If
    If Not pRes0.DataProvider.Open Then
        If Not pRes0.DataProvider.Create Then
            Debug.Assert False
            Exit Sub
        End If
    End If
    '// ** schedules
 
    Set pSchedules = pRes0.DataProvider.Schedules
    sArray = Split(sNames, ",")
    For ldx = 0 To UBound(sArray)
        pSchedules.AddNewSchedule sArray(ldx)
    Next
    pRes0.DataProvider.Save
   
    pRes0.Name = pSchedules.Item(0).Name
    pRes0.ScheduleIDs.Add pSchedules.Item(0).Id
 
    ' Add first resource to array
    arResources.Add pRes0
 
        sArray = Split(sNames, ",")
    ' Add others (exclude first one)
    For ldx = 1 To UBound(sArray)
        Set pRes1 = New CalendarResource
        pRes1.Name = sArray(ldx)
        pRes1.ScheduleIDs.Add ldx
        ' set data provider from first resource
        pRes1.SetDataProvider pRes0.DataProvider, False
 
       arResources.Add pRes1
    Next
    CalendarControl1.SetMultipleResources arResources
 
        Set NewEvent = CalendarControl1.DataProvider.CreateEvent ' error problem occurs here

    NewEvent.StartTime = Now
    NewEvent.EndTime = Now
    NewEvent.Subject = "Product Meeting"
    NewEvent.ScheduleID = 1
    CalendarControl1.DataProvider.AddEvent NewEvent
 CalendarControl1.Populate
End Sub



--
WBR,
Serge
Back to Top
Rod001 View Drop Down
Newbie
Newbie


Joined: 29 September 2006
Location: United States
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rod001 Quote  Post ReplyReply Direct Link To This Post Posted: 03 October 2006 at 2:46pm
Serge,
 
The changes work great! I am trying to develop a proof of concept for our management team and would appreciate any and all help.
After updating the code with the changes I can't seem to make the events for adding dates to show up in the calendar.
 
Thank you,
Rod001 
Back to Top
Rod001 View Drop Down
Newbie
Newbie


Joined: 29 September 2006
Location: United States
Status: Offline
Points: 25
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rod001 Quote  Post ReplyReply Direct Link To This Post Posted: 05 October 2006 at 3:01pm

Sorry for the previous question, everything did work. Things works a lot

better when you (me) cuts and paste all the code.

Thanks again,
Rod001
 
 
 
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.156 seconds.