我有以下代码,它循环遍历 TestView1 中的文档,并且对于该视图中的每个文档,循环遍历 TestView2 中的文档,执行一些操作(输出到文件)。
为了保持循环相对及时(有一堆旧文档,我只想要那些从今天或即将到来的日期标记的时间戳),我找到了当前日期的第一个文档,并存储了它的 UNID 以便该文档可以作为内部循环的起始位置(MyView2 中的文档按时间顺序排列)。
内部循环第一次正确运行,但在第二次循环中,我收到错误消息“文档不在视图 TestView2 中”。我添加了哪一行破坏了我的代码。
这是我的代码:
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim rDoc As NotesDocument
Dim mDoc As NotesDocument
Dim rView As NotesView
Dim mView As NotesView
Dim unid As String
Dim todayDateTime As New NotesDateTime("Today")
Set db = sess.currentDatabase
Set rView = db.GetView("TestView1")
Set rDoc = rView.GetFirstDocument
Set mView = db.GetView("TestView2")
Set mDoc = mView.GetFirstDocument
Set mDoc = mView.GetFirstDocumentb 'Finds the UNID of the first document of the day
Do While Not (mDoc Is Nothing)
Dim startDate As New NotesDateTime(mDoc.startDate(0))
If startDate.DateOnly = todayDateTime.DateOnly Then
unid$ = mDoc.UniversalID
Exit Do
End If
Set mDoc = mView.GetNextDocument(mDoc)
Loop
While Not (rDoc Is Nothing) 'Outer Loop
If rDoc.Site(0) = "SAMPLE" Then
<CODE>
If Not unid$ = "" Then
Set mDoc = db.Getdocumentbyunid(unid$)
While Not (mDoc Is Nothing) 'Inner Loop
If mDoc.ResourceName(0) = rName$ Then
<PRINT TO FILE CODE>
End If
Set mDoc = mView.GetNextDocument(mDoc) <--- This line here breaks the code**
Wend
End If
End If
Set rDoc = rView.GetNextDocument(rDoc)
Wend
将不胜感激任何帮助。