Doc.copytodatabase

Hi,

I keep getting a Type mismatch error with the following code, and for the life of me cannot figure it out, any ideas whats wrong here? Any suggestion would be helpful, Thanks.

Dim ws As New NotesUIWorkspace

Dim sess As New NotesSession

Dim viewname As String

Dim Server As String

Dim dbname As String

Set db = sess.CurrentDatabase

Set uidoc = ws.CurrentDocument 



viewname = uidoc.FieldGetText("View")

Server = uidoc.FieldGetText("Server")

dbname = uidoc.FieldGetText("dbname")

'Get selected documents to delete.

'Note: view must NOT have the “Collapse all when database is first opened” on View Properties.

Set dc = ws.PickListCollection( PICKLIST_CUSTOM,True, server, dbname, viewname, _

"Archive documents", "Select the documents to be archived and then click OK")



Set s = New NotesSession

Set db = s.CurrentDatabase

’ Set view = db.GetView(viewname)

’ Set doc = view.GetFirstDocument

Set Archivedb = New NotesDatabase( "DUBAPP1", "MARKETING\Sales&MarketingArchivev3.nsf")



For i = 1 To dc.Count

	Set doc = dc.GetNthDocument(i)

	Call doc.CopyToDatabase( Archivedb )

Next



Call dc.RemoveAll(True)

Call uidoc.refresh

Subject: doc.copytodatabase

David:

There are many places you could be getting the type mismatch error. I would put on your debugger and run through the code. Find what line the error is and we will be able to tell you why.

From what I can see (without knowing the line of error), I would check to make sure that doc was found. There are a couple things that look like it could cause problems. If you do not have an “Option Explicit” in your code, I would put it there. This might notify you of some problems.

This line of code “Set uidoc = ws.CurrentDocument viewname = uidoc.FieldGetText(“View”)” looks a bit odd.

Let me know the line the error is on and I can help you further.

Thanks!

Chris

Subject: RE: doc.copytodatabase

Apologies I was perhaps a bit vague in my post. the Type Mismatch error occurs on the line: Call doc.CopyToDatabase( Archivedb )and I have a handle on doc and Archivedb in question. Why the error happens mystifies me at this point. Any ideas? Thanks!

Subject: RE: doc.copytodatabase

You aren’t declaring the Archivedb variable which means it is set to the default type of “variant” which is not accepted as the parameter of the CopyToDatabase method - add a Dim Archivedb as NotesDatabase statement and you should be good to go.