HiCan someone help me with a problem I have in trying to search for a collection of dates within a view (DO) based on a field called dateopened & copying them to a folder (TR).
I have 2 input boxes & need to pull out documents between those two dates. The bit I am stuck on is using those two dates to pull out the necessary documents.
So far, my code looks like…
Dim ws As New notesuiworkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim dc As NotesDocumentCollection
Dim vc As NotesViewEntryCollection
'
Set view = db.GetView(“TR”)
Set vc = view.AllEntries
If vc.count > 0 Then
response = Messagebox(“Starting a new search will remove the results from the previous search.”+Chr(10)+_
"Do you wish to continue?",36,"Outstanding Replies Search")
If response = 6 Then 'Yes
Print “General Registry - Removing previous search results…”
Call vc.RemoveAllFromFolder( “TR” )
End If
If response = 7 Then 'No
Continue = False
End If
End If
Set view = db.GetView(“DO”)
response = Inputbox (“Please enter the first date of your search. Please enter the format of DD/MM/YYYY”, “Search Targets”)
response2 = Cdat(Format(response,“dd/mm/yyyy”))
If response2 = “” Then
Exit Sub
End If
endresponse = Inputbox (“Please enter the second date of your search. Please enter the format of DD/MM/YYYY”, “Search Targets”)
endresponse2 = Cdat(Format(endresponse,“dd/mm/yyyy”))
If endresponse2 = “” Then
Exit Sub
End If
showresponses = endresponse2 > response2
areyousure = Messagebox(“Are you sure you wish to search between the dates”, 36, “Search Replies”)
If areyousure = 7 Then 'No
Messagebox “Searching for targets reports cancelled.”, 64, “Search Targets”
Exit Sub
End If
Print “Please wait while the system finds all of the cases…”
Forall show In doc.dateopened
If endresponse2 > response2 Then
thisone = True
End If
End Forall
Set dc = view.GetAllDocumentsByKey(showresponses, False)
If dc.count = 0 Then
Messagebox "The system has found no cases of outstanding replies dating "+response, 64, “Search”
Exit Sub
End If
Set doc = dc.getfirstdocument
'variables to track progress in print bar
total = dc.count
current = 1
archived = 0
While Not (doc Is Nothing)
Set doc1 = dc.getnextdocument(doc)
percentcomplete = current*100/total
'Progress message
Print Cstr(Round(percentcomplete,0))+"% complete - searching case "+Cstr(current)+" of "+Cstr(total)
notthisone = False
Call dc.PutAllInFolder( “TR” )
archived = archived + 1
End If
Set doc = doc1
current = current + 1
Wend
Print "Searching complete - please wait while the view is refreshed ... (this can take upto 30 minutes)"
'Refresh view at end (This can take a while if a large number of documents have been moved)
Call ws.viewrefresh
Print "Searching complete - thank you for waiting"
End Sub