Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Multiple resource problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Multiple resource problem

 Post Reply Post Reply
Author
Message
scbdpm View Drop Down
Groupie
Groupie


Joined: 05 January 2007
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote scbdpm Quote  Post ReplyReply Direct Link To This Post Topic: Multiple resource problem
    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
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: 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
Back to Top
scbdpm View Drop Down
Groupie
Groupie


Joined: 05 January 2007
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote scbdpm Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2007 at 9:08pm
worked like a charm!
 
thanks for the changes!!!!!!
 
 
Back to Top
lexicon View Drop Down
Groupie
Groupie


Joined: 26 January 2007
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote lexicon Quote  Post ReplyReply Direct Link To This Post 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?
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: 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
Back to Top
lexicon View Drop Down
Groupie
Groupie


Joined: 26 January 2007
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote lexicon Quote  Post ReplyReply Direct Link To This Post 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
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.125 seconds.