Make Response Problem

Hi,

I have written the script below to create response document but it keep on pop out error message “Object variable not set” when in run until this line

“Call doc.MakeResponse(pdoc)”

Can anyone please help to check what has caused the problem ? Thanks in advance.

Dim ss As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument, pdoc As Notesdocument

Set db = ss.CurrentDatabase

Set uidoc = ws.CurrentDocument

Set adoc = uidoc.Document

createby = adoc.Createby(0)

createdate = adoc.Date(0)

docid = adoc.DocumentID(0)

id$ = Cstr(docid)

Set pdoc = db.GetDocumentByID(id$)

Call doc.MakeResponse(pdoc)

doc.Form = “Response Form”

doc.Createby = createby

doc.Date = createdate

Call doc.Save(True, False)

Subject: Make Response Problem

Hi,

It just the typo mistake…if you read out the line in your code…“Set adoc - uidoc.Document Createdby = adoc.Createby(0)”

Here you have declated adoc as NotesDocument and you are using doc further down the code…correct the mistake…and your error will get resolved.

Kaushal.

Subject: Make Response Problem

Your code

Set pdoc = db.GetDocumentByID(id$)

Call doc.MakeResponse(pdoc)

assumes that pdoc is found. You should protect your use of pdoc with the test

if not pdoc is nothing then

Subject: RE: Make Response Problem

Hi,

Yes… I found that the system cannot find the pdoc in the database. How come the document cannot be found since we already specified the id?

Subject: RE: Make Response Problem

Ching Chee,

In order to answer that question I would have to know how the DoucmentID field on adoc got its value. There are 3 possible causes that I can think of.

  1. The note referenced by DoucmentID has been removed.

  2. The note referenced by DocumentID never existed.

  3. The database is corrupt.