Skip to content Skip to navigation

Initialize a Null NotesDocumentCollection

« previous next »

There are times when it is handy to start will a null collection in a NotesDocumentCollection., for example when you want to add documents to a collection programmatically based on something other than selected documents in a view.

Two good methods for doing this are:

Method 1:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
               
Set db = session.CurrentDatabase
Set collection = db.GetProfileDocCollection("The name of a non-existent profile document")

Method 2:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim futureDate As New NotesDateTime("01/01/3001")
               
Set db = session.CurrentDatabase
Set collection = db..Search({@Nothing},futureDate, 0)

Method 1 is my usually preferred method if the database does not have a large number of profile documents.
Method 2 can be faster if there are a large number of profile documents (i.e. tens of thousands or more.)