Problem - Collection of documents between 2 dates

Hi

Can someone save my day or at least guide me in the correct direction please?

I have a view named (DO) which contains an asorted column with lots of dates in it.

Basically, from my created action button on my named (TR) folder, I am requesting the user to input 2 different dates from 2 input boxes.

I then want to gather these documents between the two dates & put them in the folder (TR).

My problem is getting the between dates into 1 collection.

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

'Remove all previous docs from the view before searching.

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 - 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")

'Get the first input date

response = Inputbox (“Please enter the first date of your search. Please enter the format of DD/MM/YYYY”, “Search Targets”)

'Ensure inputted date is correct format

response2 = Cdat(Format(response,“dd/mm/yyyy”))

If response2 = “” Then

Exit Sub

End If

'Get the second input date

endresponse = Inputbox (“Please enter the second date of your search. Please enter the format of DD/MM/YYYY”, “Search Targets”)

'Ensure inputted date is correct format

endresponse2 = Cdat(Format(endresponse,“dd/mm/yyyy”))

If endresponse2 = “” Then

Exit Sub

End If

‘’'This is where I am having trouble !!!

query$ = ""

If endresponse2 > response2 Then

If query$ = “” Then

query$ = addtoquery$

Else

	query$ = query$ + " ACCRUE "+ addtoquery$

End If

End If

'Get All documents with those dates

& put in folder TR

Set vc = view.AllEntries

Call vc.FTSearch(query$,0)



Set dc = view.GetAllDocumentsByKey(query$, False)



If dc.count = 0 Then

	Messagebox "The system has found no cases of outstanding replies dating "+response, 64, "Search"

	Exit Sub

End If

'Cycle through documents, copying to archive database and then removing from live database

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

Call dc.PutAllInFolder( “TR” )

		'Remove from live database

		'Call doc.Remove(True)

	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"

If archived > 0 Then

	Messagebox "The system found "+Cstr(total)+" cases that had outstanding replies of "+DateOpened+"."+_

	Chr(10)+" .",64,"Search Replies"

	

End If







''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

’ Wend

End Sub

Subject: Query String

The following query will retrieve documents between dates you specify. Note that response$ and response2$ are strings, not dates.

"[NameOfYourDateField] <= " & response$ & " AND [NameOfYourDateField] >= " & response2$

(I’d recommend you use a form to collect the search parameters rather than popping up those input boxes.)

Subject: I have a solution

As lawrence mentioned use form to do such type of task.

Create three fields on form.

  1. FirstDate

  2. secondDate

  3. Query

First two fields take two dates to find the documents between them.

Third field …make it computed …write formula so that we can use it as view selection formula for folder.

Then write code on “Search” button using value of Query field as view selection formula and finally refresh the folder. or rebuild the view(folder).

it is so simple. try…!!

Subject: Problem - Collection of documents between 2 dates.

Look at Designer help for NotesDateTime.TimeDifference method.