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

ChangeEvent

 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: ChangeEvent
    Posted: 01 September 2006 at 2:49am
Hello,
 
I need to update a customProperty in an event if a user drags an event on the calendar. 
 
This fires the EventChange,  after I update the CustomProperty with the new data, I do the DataProvider.ChangeEvent pEvent method. 
 

If MsgBox("Are you sure you want to Re-Schedule this Appointment?", vbCritical + vbYesNoCancel) = vbYes Then
  Dim pEvent As CalendarEvent
  Set pEvent = calCalendar.DataProvider.GetEvent(EventID)
 
  Dim sSql As String
  Dim rsUpdate As New adodb.Recordset
 
  Dim retvar
  Dim iApptID As Integer
  Dim lngClientID As Long
 
  ' pEvent Is Nothing for recurrence Ocurrence and Exception.
  ' See CalendarControl_PatternChanged for recurrence events changes.
  If Not pEvent Is Nothing Then
  
    iApptID = Val(NZ(pEvent.CustomProperties("apptid"), 0))
    lngClientID = Val(NZ(pEvent.CustomProperties("clientid"), 0))
    retvar = goADO.ExecuteSQL("UPDATE tblDataClientApptDate SET Reschedule = True Where ApptID = " & iApptID)
   
    ' Now I need to build a new tblDataClientApptDate item for the rescheduled appointment.
    ' I need the new ApptID for the new Item, and I need to put the new apptID into the Customer Property of the event.
    iApptID = NZ(CLng(NZ(VLookup("Max([ApptID]) AS NextID", GetDBName(), "tblDataClientApptDate"), 0)) + 1)
    pEvent.CustomProperties("ApptID") = iApptID
    calCalendar.DataProvider.ChangeEvent pEvent
 
This puts me into a loop. 
 
Am I doing this at the wrong place or is there an excepted way to get out of the loop.
 
 
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 September 2006 at 4:04pm
Hi,

Actually this is quite often case - when from some event handler you call method which fires this event again and you get a loop and stack overflow.
 
The idea to avoid this is to have a global semaphore of running this method, as following:

Dim g_bChangeEventRunning as Boolean
 
sub Form_Load()
    g_bChangeEventRunning = False
end sub
 
sub wndCalendar_EventChanged(......)
    OnErrOr GoTo mExit:
 
    if g_bChangeEventRunning then
        Exit sub
    end if
   
    g_bChangeEventRunning = True
   
    '------------------
    ' place your code here
    '------------------

mExit:
    g_bChangeEventRunning = False 'ensure that you reset this to false before exit this sub
 
end sub


--
WBR,
Serge
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: 10 September 2006 at 5:09pm
Thanks for the reply. I will give this a try.
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.