Solved: Open a child document from a parent document?

I have a parent form that is used to set up basic project information. On the parent form there is a button to create a child form that keeps track of different reference numbers.

The button on the parent form should create a new child document if there hasn’t been one created. When the new child is created it populates 2 fields on the parent form. One that indicates a child has been created and one that stores the child documents UNID. If there has already been a child document created instead of creating a new one I want the button to open the child document.

So far I can’t get this to work. Here is my code in my button on the parent form.

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim session As New notessession

Dim uidoc As notesuidocument

Dim doc As notesdocument

Dim view As NotesView



Set uidoc = ws.CurrentDocument

Set doc = uidoc.Document

Set view = session.CurrentDatabase.GetView("projsubnm") 	





If doc.RefDoc(0) = "" Then

	Set refuidoc = ws.ComposeDocument( "", "" , "Ref Num" )

Else

	Call view.Refresh

	Set doc = view.GetDocumentByKey(doc.RefDocUnid(0),True)

	If Not (doc Is Nothing) Then

		Set uidoc = ws.EditDocument(True)

	End If 

	

End If

End Sub

When the button is clicked nothing happens. All the code executes but the child form does not open.

Any ideas?

Subject: Here is my solution code.

Just took a little tweeking. Here is my solution code…

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim session As New notessession

Dim parentuidoc As notesuidocument

Dim uidoc As notesuidocument

Dim Parentdoc As notesdocument

Dim doc As NotesDocument

Dim view As NotesView

Dim db As NotesDatabase



Set db = session.CurrentDatabase

Set parentuidoc = ws.CurrentDocument

Set Parentdoc = parentuidoc.Document





If Parentdoc.RefDoc(0) = "" Then

	Set refuidoc = ws.ComposeDocument( "", "" , "Ref Num" )

Else

	

	Set doc = db.GetDocumentByUnid(Parentdoc.RefDocUnid(0))

	

	If Not (doc Is Nothing) Then

		Set uidoc = ws.EditDocument(True, doc, False, , False, True)

	End If 

	

End If	

End Sub