Dim Session As New NotesSession
Dim dbCur As NotesDatabase
Dim dc As NotesDocumentCollection
Dim docCur As NotesDocument
Dim View As NotesView
Dim doc As Notesdocument
Set dbCur = Session.currentdatabase
Set docCur = Session.documentcontext
Dim dt As New NotesDateTime("")
Dim formula As String
formula="(form="""+"AFLForm"+""")"
If docCur.KeyWord(0)<>"" Then'
formula=formula+"&(ApplyName="""+docCur.KeyWord(0)+""")"
End If
'开始时间
If docCur.DateFrom(0)<>"" Then
a=Trim(Format$(docCur.DateFrom(0),"yyyy-mm-dd hh:nn"))
formula=formula+"&(FromDate=>["+a+"])"
End If
'结束时间
If docCur.DateTo(0)<>"" Then
b=Trim(Format$(docCur.DateTo(0),"yyyy-mm-dd hh:nn"))
formula=formula+"&(ToDate<=["+b+"])"
End If
'这样实现数据库搜索
Set dc = dbCur.search(formula,dt,0)
'清空搜索文件夹
Set View = dbCur.getView("SearchResult")
If Not View Is Nothing Then
Set doc = View.getfirstdocument
While Not doc Is Nothing
Call doc.removefromfolder("SearchResult")
Set doc = View.getfirstdocument
Wend
End If