Copy all documents from many databases to one

OK here is my issue. I am getting the error message “variant has no object” when this agent is run. I know that a variant that is a number can be concatenated with a string. so what am I missing here? thanks in advance for any insight.

Sub Initialize

Dim session As New NotesSession

Dim currentDB As NotesDatabase

Dim db As Notesdatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Set currentDB = session.CurrentDatabase

server = “server1/independent”

Dim AvariantV As Variant

AvariantV = 10

For AvariantV= 10 To 12

Set db = s.GetDatabase.server( “store0” + AvariantV +“.nsf”)

Set view = db.GetView(“($Contacts)”)

Set dc = view.getAllDocuments()

Set doc = dc.GetFirstDocument().copytodatabase(currentDB)

While Not(doc Is Nothing)

Set doc = dc.GetNextDocument(doc).copytodatabase(currentDB)

Wend

Next

End Sub

Subject: RE: copy all documents from many databases to one

I see something in this code that might be contributing to the issue.

In this area:

Set db = s.GetDatabase.server( “store0” + AvariantV +“.nsf”)

I am assuming “s” is for session, but I don’t see a “Dim s As New NotesSession”, but I do see a “Dim session As New NotesSession”.

Also, I am not sure if performing a method of type:

session.GetDatabase.server(…)

is valid

It would be much better to go ahead and use the conventional:

session.GetDatabase(…)

Subject: RE: copy all documents from many databases to one

oops yes you are right. thanks for catching the variable “s” should have been “session”. and you are very right, the syntax on the getdatabase method does take 2 parameters “string server and string database name”.

ok I’m almost there. I am now getting an error that says the database is no open. (the ones I am trying to open to copy docs from). what method or function would I need for this?

Subject: Hope this helps

Dim session As New NotesSessionDim currentDB As NotesDatabase

Dim db As Notesdatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Set currentDB = session.CurrentDatabase

server = “server1/independent” 'If the databases are on the same server use db.server

server = currentdb.server

Dim AvariantV As Variant

AvariantV = 10 'no need for this… your for next is looping from 10 to 12… and us an Integer for that.

For AvariantV= 10 To 12

Set db = session.GetDatabase(server,"store0" & AvariantV & ".nsf") ' the & will convert everything a string regardles of it is an integer or variant or string

Set view = db.GetView("($Contacts)")

Set dc = view.getAllDocuments()

Set doc = dc.GetFirstDocument

While Not(doc Is Nothing)

	call doc.copytodatabase(currentDB)

	set doc = dc.GetNextDocument(doc)

wend

Next

'alternative way is without the DC

Dim session As New NotesSession

Dim currentDB As NotesDatabase

Dim db As Notesdatabase

Dim doc As NotesDocument

Set currentDB = session.CurrentDatabase

server = currentdb.server

Dim AvariantV As integer

For AvariantV= 10 To 12

Set db = session.GetDatabase(server,"store0" & AvariantV & ".nsf") ' the & will convert everything a string regardles of it is an integer or variant or string

Set view = db.GetView("($Contacts)")

Set doc = view.GetFirstDocument

While Not(doc Is Nothing)

	call doc.copytodatabase(currentDB)

	set doc = view.GetNextDocument(doc)

wend

Next