I am getting a user to type a value in a text field.I need a code that can use this value to go thru all documents in a specified view, returning the docs with the same value on a specific field as the one in the textfield.
Subject: Document Search
Shortest:
searchString = |(field to compare=“| + field value + |”)&(view selection formula of your view)|
set resultsColl = curDb.Search(searchString, Nothing, 0)
Replace:
field to compare - name of the text field
field value - name of the variable holding the text field value
view selection formula of your view - since you want to get results from a specified view only, your search must include the same criteria as the view, i.e. use the part after SELECT from view selection formula.
More correct:
The above is simple and quick, but not good if your database is big. In that case, you need to cycle through documents in your view, e.g. this way:
Dim session as new Notessession
Dim db as notesdatabase
dim doccoll as notesdocumentcollection
dim doc as notesdocument
dim view as notesview
set db = session.currentdatabase
set view = db.getview(your view)
'create an empty collection (small trick:)
set doc = db.createdocument
set doccoll = doc.responses
'now cycle through view and add matches to your collection
set doc = view.getfirstdocument
while not (doc is nothing)
if your field = your value then
call doccoll.add(doc)
end if
set doc = view.getnextdocument(doc)
wend
Some replacing in this code too, enjoy:)