Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db.Search

Status
Not open for further replies.

andrdoba

Technical User
Aug 13, 2002
16
GB
Hi guys,
I am having difficulties to get the searchFormula$ right. I need to find a COLLECTION of documents using db.Search where the FORM is called CM and field on the form is called TheMeasurement should equal TEST1

Can anybody help, Thanks
Andre
 
Andre,

There is a better way than db.search to collect documents in a database. I have had problems with inaccurate results and have been told that it is common. Here is a better way to gather your documents.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim Collection As NotesDocumentCollection
Dim doc As NotesDocument, oldDoc As NotesDocument

Set db = Session.currentdatabase
'create a hidden view name = Measurement or FormView
'first column = TheMeasurement or Form
'sort first column
Set view = db.getview("Measurement") 'or FormView

'value needs to be "CM" if you did a FormView, if you did the measurement view then it would be "Test1"

Set collection = trialview.GetAllDocumentsByKey(value)

'If you then need to step through the collection to find
'other documents that match a different criteria then:

If collection.count > 0 Then
Set doc = collection.GetFirstDocument
Do While Not doc Is Nothing
Set item = doc.GetFirstItem("EventStartTime")
requesttime = Format(item.text, "HH:MM AM/PM")
If requesttime <= checktime Then
amcount = amcount + 1
Elseif requesttime > checktime Then
pmcount = pmcount + 1
End If
Set olddoc = doc
Set doc = collection.getnextdocument(olddoc)
Delete olddoc
Loop
End If

This looks at a collection of documents. As long as the documentcollection isn't empty it will continue the loop. I have gathered all the documents where the date matches my criteria. Then I assign the value of the EventStartTime to a variable and check to see if I need to increment my AMcount or my PMcount depending on the time. Then I assign the document to olddoc, assign the next document in the collection to doc and delete olddoc (the one I just counted) from the collection (which is how the collection eventually gets emptied!).


Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
THANKS Leslie, this looks quite helpful to me
ANDRE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top