Print Page | Close Window

CustomProperties: error 440 object no longer valid

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=15630
Printed Date: 20 July 2025 at 1:14am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CustomProperties: error 440 object no longer valid
Posted By: Nexxes
Subject: CustomProperties: error 440 object no longer valid
Date Posted: 15 November 2009 at 4:38pm
This deal is with CUSTOMPROPERTIES i need to add to each event object
because I want to manually control all data saved to my access database
and need the ID of each record.
 
I have two forms frmCalendar which contains the calendar control and
the ADD EVENT Form called frmEvent_AddEdit which allows me to create/edit an event.
 
On the calendar dblcick event I call the ADD NEW EVENT form which
allows me to add a new event. In that form I create a new event
and use the ADD EVENT method of the calendar to add the new event.
 
In the new event I add a custom property AppointmentID to store the ID of the access database record
I am also creating manually to store the event in my access database.
 
Here is the Code in the frmEvent_AddEdit that creates the event and adds to calendar.
I want to save the event to my internal access daabase triggered byt the EventAddedEx EVENT.
 
Private Sub cmdOk_Click()
    If (Not CheckDates()) Then Exit Sub
    UpdateEventFromControls
   
    If m_bAddEvent Then
        'We have to CREATE A new APPOINTMENTID from adding the new record and create event so it saves it HERE
        Dim nRS As New ADODB.Recordset
        With nRS
            .CursorLocation = adUseClient
            .CursorType = adOpenDynamic
            .LockType = adLockOptimistic
            .Open "Select * from Appointments where AppointmentID = 0", FIDOCon
            .AddNew
                .Fields("subject") = txtSubject.Text
            .Update
        End With
        m_pEditingEvent.CustomProperties.Property("AppointmentID") = nRS.Fields("AppointmentID")
        nRS.Close
        Set nRS = Nothing
               
        frmCalendar.nakCalendar.DataProvider.AddEvent m_pEditingEvent
    Else
        frmCalendar.nakCalendar.DataProvider.ChangeEvent m_pEditingEvent
    End If
    Unload Me
End Sub
 
Code that errors in the frmCalendar form that contains the calendar control on the MSGBOX line (errror 440)
 
Private Sub nakCalendar_EventAddedEx(ByVal pEvent As XtremeCalendarControl.CalendarEvent)
       'RUNS WHEN A NEW EVENT IS ADDED TO THE CALENDAR
       MsgBox "pEvent.CustomProperties.Property('AppointmentID')" & pEvent.CustomProperties.Property("AppointmentID")
end Sub
 
As you can see I am creating a new record in my access database and getting the ID
and creating the AppointmentID customproperty and storing that in the NEW EVENT.

I add the event which triggers the nakCalendar_EventAddedEx which errors saying the customproperty
isnt created or exists. Why is this?
 
thanks all
Nate Kern
 



Replies:
Posted By: Nexxes
Date Posted: 16 November 2009 at 7:32pm
I have figured out the problem that the devs shouldbe aware of.
 
IF i pass the VALUE to the customproperty as the recordset object,
the SECOND i close the recordset object the CUSTOMPROPRETY gets removed
from the collection. I would think that it should not be.

What I did to fix the problem is pass the recordset value to a temp variable
and now when I pass the variable to set the value of the customproperty it
doesnt get destroyed or remove the property when the recordset object is closed.
 
In my ADD EVENT form the code the errored once the form was closed and I
tried to access the eventID customproperty I had created is:
m_pEditingEvent.CustomProperties.Property("AppointmentID") = nRS.Fields("AppointmentID")
To fix it.. do this
Dim temPID as long
tempid = nRS.Fields("AppointmentID")
m_pEditingEvent.CustomProperties.Property("AppointmentID") = tempID
 
NOW when I add the event and close the recordset and try and access the
customproperty from the Event AddedEx or EventchangedEx  the AppointmentID customproperty is
still in the collection.
 
 



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