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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching and counting documents 1

Status
Not open for further replies.

jumpjack

Programmer
Jul 28, 2006
79
0
0
IT
I found out how to look for specified documents and how to count documents having specified values in specified fields, in a fast way: use db.SEARCH function .

Example:
How many documents use "MainForm" form and have "7" value in "DocIcon" field?

That's easy:


Code:
Dim session As Object
Dim db As Object
Dim GlobalCOllection As Object

Set session = CreateObject("Lotus.Notessession") ' Connect to Lotus 7. Use "Notes.Notessession" for previous releases.
Call session.Initialize(riga) ' Only Lotus 7 allows login from external application
Set db = session.GETDATABASE(SERVER, DBNAME) ' Open DB

field1 = "Form"
value1 = "MainForm"

field2 = "DocIcon"
value2 = "7"

SearchString$ = field1 & " = " & """" & value1 & """" & " & " & field2 & " = " & value2
Set GlobalCollection = db.SEARCH(SearchString$, Nothing, 0)

c=GlobalCollection.count

Resulting searchstring$ value:
Form = "MainForm" & DocIcon = 7

(' & """" ' allows adding quotes inside a string. )


You can also limit search to documents modified after a specified date, by replacing "Nothing" with a StartDate variable defined like this:

Code:
Dim session As Object
Dim db As Object
Dim GlobalCOllection As Object

Dim datetime As Object
Dim DateString as string

DateString = "25/02/2006"
Set datetime = session.CREATEDATETIME(DateString) ' Convert date to Notes format
Set session = CreateObject("Lotus.Notessession") ' Connect to Lotus 7. Use "Notes.Notessession" for previous releases.
Call session.Initialize(riga) ' Only Lotus 7 allows login from external application
Set db = session.GETDATABASE(SERVER, DBNAME) ' Open DB

field1 = "Form"
value1 = "MainForm"

field2 = "DocIcon"
value2 = "7"

SearchString$ = field1 & " = " & """" & value1 & """" & " & " & field2 & " = " & value2
Set GlobalCollection = db.SEARCH(SearchString$, datetime, 0)

c=GlobalCollection.count

-- Jumpjack --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top