Copy Appointment doc into another database?

I have encountered a problem whilst developing a group calendar application.

I followed the paper: “Integrating C&S into a group application”

http://www-10.lotus.com/ldd/today.nsf/62f62847467a8f78052568a80055b380/643ef8419b72f66f85256485005505bc?OpenDocument

It suggests to create a copy of a new appointment doc in the group calendar database in the QueryClose event using code. The problem I have is that when I try to do this I get an error “Invalid or non-existent document(mail\maildbname.nsf)”

I find that if I reopen the Appointment doc in my mail database and then save it again - it then works correctly and copies the doc into the new database.

I have tried PostSave event too and I get the same error.

There is some code called from the QueryClose event by default: “Call csEventObj.QueryClose( Continue)”

I traced this down and placed my copy code in here and I still got the same error. How do I copy a new appointment doc into another database when it is created?

My copy code:

Dim IQMSdb As New NotesDatabase( “servername” , “path/to_database.nsf” )

Dim curdoc As NotesDocument

Set curdoc = source.Document

Call curdoc.CopyToDatabase( IQMSdb )