Why will this not compile?

STick this in a page button initialise eventand try and save, it will come up with a type mismatch error:

Dim ns As New NotesSession

Dim dbUat, dbLive As NotesDatabase



Dim ndc As NotesDocumentCollection

Dim doc  As NotesDocument



'Clear current database

Set dbUat = ns.CurrentDatabase

Set ndc = dbUat.AllDocuments

Call ndc.RemoveAll(True)



Set dbLive = ns.GetDatabase("BP1XEULA003", Replace(dbUat.filepath, "/UAT", ""))



If dbLive.isopen Then

	

	Set ndc = dbLive.AllDocuments

	Set doc = ndc.GetFirstDocument

	While Not(doc Is Nothing)

		Call doc.CopyToDatabase(dbUat)

		Set doc = ndc.GetNextDocument(doc)

	Wend

	Print "done"

Else

	Print "Failed to open live database"

End If

'curiously if you then

change the

Dim doc As NotesDocument

to

Dim doc, pooh As NotesDocument

or put the dbUat dbLive declarations

on separate line it will compile.

WEIRD - any ideas?

Subject: strange, but possibly the answer linked to the fact

that:Dim dbUat, dbLive As NotesDatabase

is equivalent of:

Dim dbUat as Variant, dbLive As NotesDatabase

not

Dim dbUat As NotesDatabase, dbLive As NotesDatabase

as would be the case in VB.

So unless you want to leave your objects as Variant, you’d rather use the full form. Why it fails to compile though beats me.