Losing Handle on Doc when trying to open in Frameset

I have a Survey and a Profile document that I need to be able to compare, preferably side-by-side.From a view, I’ll select the Survey and hit the action button on the view to “Review”. That button has code to locate the associated Profile document and open both the Survey and the Profile in a frameset.

The code stops at the indicated point. It feels as if it is losing a handle on the Profile (bpdoc) … but never when I run in debug mode. That always works. Running in ‘normal’ mode, without the debugger, I get the Survey opening in the ‘Survey’ frame and the default blank page in the ‘Profile’ frame.

Any thoughts, ideas, recommendations greatly appreciated.

Dim s As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim bpdoc As NotesDocument

Set db = s.CurrentDatabase

Set view = db.GetView(“Brokers by UNID_Broker”)

Set coll = db.Unprocesseddocuments

Set doc = coll.GetFirstDocument

'Get UNID and Broker Profile doc

Print "Locating Profile document … "

Set bpdoc = view.GetDocumentByKey(doc.UNID_Broker(0), True)

If bpdoc Is Nothing Then

Msgbox "Cannot locate BP doc for " & doc.BrokerName(0)

Exit Sub

End If

'Open frameset and set frame values

Call ws.SetTargetFrame(“”)

Call ws.OpenFrameSet(“Review” )

Msgbox “open frameset”

Call ws.SetTargetFrame(“Survey”)

Msgbox "set survey frame - " & doc.BrokerName(0)

Msgbox "got bpdoc - " & bpdoc.BrokerName(0)

Call ws.EditDocument(False, doc, True, , False, False)

*** CODE STOPS HERE ***

Msgbox “set doc”

Call ws.SetTargetFrame(“Profile”)

Msgbox “set profile frame”

Call ws.EditDocument(True, bpdoc)

Msgbox “set bpdoc”

Msgbox “end”