Print Page | Close Window

Multiple resource problem

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=6017
Printed Date: 27 September 2024 at 4:27pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Multiple resource problem
Posted By: scbdpm
Subject: Multiple resource problem
Date Posted: 06 January 2007 at 4:53pm
I have the code below which loads my resources ('Schedules') and Events/appointments from my Access DB wonderfully!
 
However, it appears to be 'shifted'. What I mean by that is the the same appointments are showing in the first two columns (i.e. resources) and then the appointments that are supposed to be in the second column is in the third and so on......
 
Here is code:
 
Public Sub LoadSchedule(dtNewDate As Date)

Dim arResources As New CalendarResources
    Dim pRes0 As New CalendarResource
    Dim pRes1 As New CalendarResource
   
    pRes0.SetDataProvider2 "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data\Events.mdb", 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
    Dim pSchedules As CalendarSchedules
    Set pSchedules = pRes0.DataProvider.Schedules
   
    If pSchedules Is Nothing Then
        Exit Sub
    End If
   
   
    '// ** resources
   
    pRes0.Name = pSchedules.Item(0).Name
    pRes0.ScheduleIDs.Add pSchedules.Item(0).Id
    arResources.Add pRes0
   
   
    pRes1.SetDataProvider pRes0.DataProvider, False
   
     Dim ldx As Integer
    For ldx = 1 To pSchedules.Count - 1 'changed Ubound(sarray)
        Set pRes1 = New CalendarResource
        pRes1.Name = pSchedules.Item(ldx).Name ' sArray(ldx)
        pRes1.ScheduleIDs.Add ldx
        ' set data provider from first resource
        pRes1.SetDataProvider pRes0.DataProvider, True
        arResources.Add pRes1
    Next
      
    CalendarControl.SetMultipleResources arResources
    CalendarControl.ActiveView.DayHeaderFormatLong = "mm/dd/yyyy"
   
    CalendarControl.Populate
    CalendarControl.DayView.ShowDays dtNewDate, dtNewDate
   
    End Sub



Replies:
Posted By: sserge
Date Posted: 09 January 2007 at 1:36pm
Look below for the fixed code:

'// ** resources

pRes0.Name = pSchedules.Item(0).Name
pRes0.ScheduleIDs.Add pSchedules.Item(0).Id
arResources.Add pRes0

'' no need for this line here
'' pRes1.SetDataProvider pRes0.DataProvider, False

Dim ldx As Integer
For ldx = 1 To pSchedules.Count - 1 'changed Ubound(sarray)
Set pRes1 = New CalendarResource
pRes1.Name = pSchedules.Item(ldx).Name ' sArray(ldx)
'' !!! main BUG is here !!!
'' The ID must be specified there, not index
'' pRes1.ScheduleIDs.Add ldx

pRes1.ScheduleIDs.Add pSchedules.Item(ldx).Id ' the same way as for pRes0
' set data provider from first resource
' second parameter value should be False
' no a big bug, but you can have problems due this
'' pRes1.SetDataProvider pRes0.DataProvider, True

pRes1.SetDataProvider pRes0.DataProvider, False

arResources.Add pRes1
Next


--
WBR,
Serge


Posted By: scbdpm
Date Posted: 09 January 2007 at 9:08pm
worked like a charm!
 
thanks for the changes!!!!!!
 
 


Posted By: lexicon
Date Posted: 01 February 2007 at 7:38am
I wrote the code to make a multiple schedule calendar and i added 2 schedules
 
When i'm adding a event in schedule 1 then it appears and in schedule 2
but, when i'm addind a event to schedule 2 then it appears only in schedule 2
 
Tha data in database is correct but the display of them is wrong
 
What i'm doing wrong?


Posted By: sserge
Date Posted: 01 February 2007 at 1:56pm
Most likely you incorrectly configured Resources. Your first resource looks to contain both schedule 1 and schedule 2, but it should contain only schedule 1.

--
WBR,
Serge


Posted By: lexicon
Date Posted: 01 February 2007 at 2:51pm
I have 4 rooms and when i'm adding events for each one the data in access db shows correctly the field scheduleID as 1,2,3,4 correct
 
But in Calendar displays all 4 events for everyone
 
Sorry I'm new here, How to configure resources?
 
I'm using the example on your code without any modifications, only i change the dataprovider for the nultischedule from .xml to .mdb



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