Sub Click(Source As Button)
Dim db As New NotesDatabase( "Byzantium", "discuss.nsf" )
Dim view As NotesView
Dim doc As NotesDocument
Dim parentDoc As NotesDocument
Set view = db.GetView( "By Category" )
If view Is Nothing Then
Messagebox "View not found"
Exit Sub
End If
Set doc = view.GetLastDocument
If doc Is Nothing Then
Messagebox "Last document not found"
Exit Sub
End If
If doc.IsResponse Then
Set parentDoc = view.GetParentDocument( doc )
If parentDoc Is Nothing Then
Messagebox "Error reading parent document"
Exit Sub
End If
Messagebox parentDoc.UniversalID, , _
"UNID of parent of last document"
Else
Messagebox doc.UniversalID, ,"UNID of last document"
End If
End Sub
Function getAncestor ( doc As NotesDocument ) _
As NotesDocument
Dim view As NotesView
Set view = doc.ParentView
If Not(Doc Is Nothing) Then
While doc.IsResponse
Set doc = view.GetParentDocument( doc )
Wend
End If
Set getAncestor = doc
End Function