Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - CustomProperties: error 440 object no longer valid
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CustomProperties: error 440 object no longer valid

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


Joined: 13 November 2009
Location: United States
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nexxes Quote  Post ReplyReply Direct Link To This Post Topic: CustomProperties: error 440 object no longer valid
    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
 
Back to Top
Nexxes View Drop Down
Newbie
Newbie


Joined: 13 November 2009
Location: United States
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nexxes Quote  Post ReplyReply Direct Link To This Post 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.
 
 
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.047 seconds.