DB search and leave docs in a view

I am trying to give a user an easy way to enter information into a field, i.e. a name. Then when a button is pushed an agent would do a search for documents in the database that have that value. Then when found would leave them in a view. Basically I am looking for the same type of function the search bar in a view achieves but from a form. I have used many types of searches to find and open or edit documents doing a document collection, but in this case I don’t want to open them I just want to leave them in a view for there could be many documents found by the search.

Subject: DB search and leave docs in a view

Mark, I use the following script to look for a certain string in a field. If its present, it adds the document to a folder. Otherwise, it gets skipped. you could probably tweak this to get what you are looking for. Note, this requires your DB to be Full-Text-Indexed.

Sub Initialize

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim profileDoc As NotesDocument

Dim currDoc As NotesDocument 

Dim Recipients ( 1 To 3 ) As String

Dim i As Integer

Dim arr() As NotesDocument

Dim vInitialized As Variant

vInitialized = False

Set session = New NotesSession

Set db = session.CurrentDatabase

Set dateTime = New NotesDateTime("03/01/2005")

Set collection = db.UnprocessedSearch("@Contains(Field;""String"")",dateTime, 0)

If collection.Count > 0 Then

	For dci = 1 To collection.Count

		vDup = False

		Set currDoc = collection.getNthDocument( dci )

		Redim Preserve Arr(1 To dci ) 

		If vInitialized Then

			Forall docX In arr

				If docX.UniversalId = docX.UniversalID Then

					vDup = True

					Exit Forall

				End If

			End Forall

		End If

		If Not vDup Then

			If vInitialized Then Redim Preserve arr(Ubound(arr) + 1 ) As NotesDocument

			Set arr(Ubound(arr)) = currDoc

		End If

		vInitialized = True

	Next

End If



For j=1 To collection.Count

	Set currDoc = collection.GetNthDocument(j)

	Call currDoc.PutInFolder("Survey")

Next

End Sub