The Document is not in view

On the following code I am getting the error “The document is not in view ”. It is getting the handle to the doc I have selected just fine but produces the error on the line of code with the *.

Any ideas are greatly appreciated!

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim view As NotesView

Set view = db.GetView("All")

view.AutoUpdate = False 

Dim doc As NotesDocument, doc2 As NotesDocument

Dim currNum As Integer

Set doc = session.DocumentContext

currNum = doc.SeqNum(0)

*Set doc2 = view.GetPrevDocument(doc)

doc.SeqNum = currNum - 1

doc2.SeqNum = currNum

Call doc.Save(False, False)

Call doc2.Save(False, False)

Call view.Refresh

End Sub

Subject: The Document is not in view

More info: This code sits behind an action button on the view.

Thanks

Subject: The Document is not in view

I think what’s happening here is that when you get a document with DocumentContext, the document doesn’t know what view it came from. This is just not going to work. You will need to scan the view to find the other document you need to modify.