获取 Notesdocumentcollection 的空计数

Getting null count for Notesdocumentcollection

最初我的问题是我遇到了溢出,因为前两个字段 (ID) 中的值的长度较长,而那时我使用的是 Clng (long)。我不得不将其更改为 Cstr(字符串)。

我还更新了视图@Text(fieldname) 中的前两列,它仍然按升序排序。

我有 4 个键,前两个键来自父窗体(但我在对话框窗体中也提供了它),第三个和第四个键来自对话框窗体。

代码片段如下:

Set lookupdb = session.GetDatabase(lserver$,ldb$)
Set lookupview = lookupdb.GetView(lview$)

Set dateRange = session.CreateDateRange()
Set dateRange.StartDateTime = dateTime1
Set dateRange.EndDateTime = dateTime2

'Variant because of the daterange in keys (4)
Dim keys( 1 To 4 ) As Variant 

keys(1) = Cstr(uidoc.FieldGetText("FirstID"))
keys(2) = Cstr(uidoc.FieldGetText("SecondID"))
keys(3) = Trim(uidoc.FieldGetText("Station"))
Set keys(4) = daterange

'Test. This has output. For daterange I used .text so I can see output.
Msgbox keys(1)
Msgbox keys (2)
Msgbox keys (3)
Msgbox daterange.text

Set lookupcoll = lookupview.GetAllDocumentsByKey(keys,True)
If lookupcoll.Count <> 0 Then
    Print "Criteria Selection Count : " + Cstr(lookupcoll.count)
    Set lookupdoc = lookupcoll.GetFirstDocument
    ctr = 0
    Do While Not lookupdoc Is Nothing 
        <code here>
    Loop

    Print "Ended : " + Now()


Else
    Messagebox "No Document Retrieved."
End If

Exit Sub

我正在获取 "No Document Retrieved",当我检查文档集合时,它有 0。

请告诉我为什么我会变成空值。非常感谢。

GetAllDocumentsByKey 方法要求您的视图 lookupview 的前几列按您用来搜索它的键进行分类和排序。

来自docs

GetAllDocumentsByKey method

Finds documents based on their column values within a view. You create an array of strings (keys), where each key corresponds to a value in a sorted and categorized column in the view. The method returns the all documents whose column values match each key in the array.

您可能需要更改视图的设计以适应您正在执行的搜索。