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

If document doesn't exist!

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
0
0
US
Hello all,

I am trying to write a LotusScript that will:
1. Look in the database to see if a document exists by checking a field for a value (Collected by a inputbox)
2. if the document exists - exit the sub
3. if there is NO Document - continue.

Any suggestions?

Thanks,

la
 
I think You need something like this:

Dim searchstring$
Dim coll As Notesdocumentcollection
Dim session As New Notessession
Dim db As Notesdatabase
' suppose your db is the current db
Set db=session.Currentdatabase
searchstring$=Inputbox(" ... ' You know this function
' Trimming extra spaces
searchstring$=Trim$(searchstring$)
If Not searchstring$="" Then
Set coll=db.Search(|fieldname="|+searchstring+|"|,0)
If coll.Count>0 Then
' ...continue here
End If
Else
Msgbox "Interrupted by user!"
End If

Remember: db.Search can be too slow for your need, create a sorted view on field fieldname and populate the collection with:

Set coll=view.getalldocumentsbykey(searchstring$,True)

where view is a Notesview object created by:
Set view=db.Getview("viewname")

the last boolean param can be set to False if you don't need an exact match.

If you are looking for a single document try to use Getdocumentbykey, in this case you don't need a document collection saving resources.

Hope will be helpful.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top