Error[91]**: Object variable not set

I have a function called processAttendee, it contains 2 other functions one called udpateCalendar, one called updateItinerary.

function processAttenee(…)

dim calDoc as notesdocument

......

rs1 = updateCalendar(calDoc .....)

rs2 = updateItinerary(calDoc ....)

.......

End Function

I declare calDoc in function , the object is modified in function updateCalendar() with calDoc passed to it as an parameter…

However, I got an “Error[91]: Object variable not set” error when I tried to access calDoc in function .

Here are two basic facts:

  1. calDoc referes to calendar document residing in respective mail db.

  2. function resides in an agent running on a customized application database.

I did find a way to solve this problem after reading up in the forum on a similar but different problem…

What I did was I also declared an obj. variable calDb to hold the handle on the mail db which contains the calDoc object… and pass it to function … this solved the problem…

So I guess the reason I lost handler on the object “calDoc” was because I didn’t keep the container of the object alive in the scope of …

However, what puzzles me is the fact I can run the agent fine manually… (needs to point out that i am testing using my own mail db on my machine but still…)…

I might have missed some very basic thing about object scoping… but I need someone to help to set me straight once for all. thanks!!!

Steve