PLEASE HELP - URGENT! doc.MakeResponse

I have the following code in a button…If I take out the line ‘Call checkDoc.MakeResponse(doc)’ - it runs fine - but with that line in there I get a ‘Type Mismatch’ error. The error is from that line…Why? I’ve used .MakeResponse before - no problems…HELP!!!

Sub Click(Source As Button)

Dim wksp As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim oldView As NotesView

Dim vc As NotesViewEntryCollection

Dim oldVc As NotesViewEntryCollection

Dim entry As NotesViewEntry

Dim oldEntry As NotesViewEntry

Dim x As Long

Dim k As Long

Dim dels() As String

Dim oldDels() As String

Dim message As String



Set uidoc = wksp.CurrentDocument

Set doc = uidoc.Document

Set db = session.CurrentDatabase

Set view = db.GetView("setupDeliverables")

Set oldView = db.GetView("web")

Set vc = view.GetAllEntriesByKey("Remits", True )

Set oldVc = oldView.GetAllEntriesByKey(doc.unid(0) + "~" + doc.webName(0) + "~Remits",True)

Dim listChoice As Variant



If vc.Count<>0 Then

	Redim dels(vc.Count-1)

	Set entry = vc.GetFirstEntry()

Else

	Messagebox("There are no Remit Deliverables to chose from.")

	Exit Sub

End If

If oldVc.Count<>0 Then

	Redim oldDels(oldVc.Count-1)

End If

For x = 0 To (vc.Count-1)

	dels(x) = entry.ColumnValues(1)

	Set entry = vc.GetNextEntry(entry)

Next x

listChoice = wksp.Prompt(PROMPT_OKCANCELLISTMULT,"Remits Deliverables","Please select the Remits Deliverables you would like to add.",,dels)

If Not Isempty(listChoice) Then

	For x = 0 To Ubound(listChoice)

		If (listChoice(x)<>"") Then

			If oldVc.Count<>0 Then

				Set oldEntry = oldVc.GetFirstEntry()

				message = ""

				For t = 0 To (oldVc.Count-1)						

					If (oldEntry.ColumnValues(1) = listChoice(x)) Then

						message = "There is already a " + doc.webName(0) + " deliverable for " + listChoice(x) + " - the system will NOT create another one."

						Exit For

					Else

						Set oldEntry = oldVc.GetNextEntry(oldEntry)

					End If

				Next t

			End If

			If (message = "" ) Then

				Set checkDoc = db.CreateDocument

				checkDoc.form = "deliverables"

				checkDoc.hospitalName = doc.hospitalName(0)

				checkDoc.type = "Web Server - " + doc.webName(0)

				checkDoc.deliverable = "Remits"

				checkDoc.name = listChoice(x)

				checkDoc.unid = doc.unid(0)

				checkDoc.mainKey = doc.mainKey(0)

				Call checkDoc.MakeResponse(doc)

				Call checkDoc.Save(True,True)

			Else

				Messagebox(message)

			End If

		End If

	Next x

End If

End Sub

Subject: PLEASE HELP - URGENT! doc.MakeResponse

I have it working now - but not sure why it wasn’t. I had uidoc & doc declared in the global variables…wouldn’t work…so I declared them in the button as well - and it worked…I think it is because I have a header on the form.

Thanks

Subject: Possibly a new Document?

The MakeResponse will fail if the doc has not been saved (does not have a UNID). Try the following:

checkDoc.mainKey = doc.mainKey(0)

If doc.IsNewNote Then Call doc.Save(True, True)

Call checkDoc.MakeResponse(doc)

Call checkDoc.Save(True,True)