Small problem with scipt...object varibable not set

hi,

OK Below is part of a script I wrote. It keeps coming up with the error object varible not set. I know what that is. But can’t see it were it is??

In the script, we get to that first message box “do we get here1” but not to the 2nd one that says do we get here2".

I know another set of eyes will see the error in a minute…or less…lol

thanks Kevin M.

Sub Initialize

Dim session As New notessession

Dim db As notesdatabase

Dim  doc As notesdocument

Dim view As notesview

Dim dataview As notesview

Dim datadoc As notesdocument

Dim datapath As String

Dim data As notesdatabase

Dim statdoc As notesdocument

Dim emails As Integer

Dim attachments As Integer

Dim rtitem As Variant

Dim eval As Variant

Dim item As notesitem

Dim EncMails As Integer

Dim foldername As String

Dim sKeepPrivate

Dim sPrivateEmails As String 



emails = 0 

attachments = 0 

sPrivateEmails = ""

Set db = session.currentdatabase

Set view = db.getview("STATPRO")

Print ("Checking Status")

Set statdoc = view.getfirstdocument

If Not statdoc Is Nothing Then

	datapath = statdoc.datapath(0)

	Set data  = session.getdatabase("",datapath,False)

	Messagebox("DO WE GET HERE1")

	If data.isopen Then

	Messagebox("DO WE GET HERE2")

		Set dataview = data.getview("($All)")

		Set datadoc  =   dataview.getfirstdocument

		While Not datadoc Is Nothing

			emails = emails+1

			eval = Evaluate("@Attachments", datadoc)

			If  Isnumeric(eval(0)) Then  ' find Attachments

				If Cint (Cstr(eval(0)))  > 0 Then

					attachments = attachments + Cint (Cstr(eval(0)))  

				End If

			End If

			

			sKeepPrivate = Cstr( datadoc.GetItemValue("$KeepPrivate")(0) )

			If sKeepPrivate = "1" Then

				EncMails = EncMails + 1

				Messagebox("DO WE GET HERE3")

				sPrivateEmails = sPrivateEmails & (datadoc.GetItemValue("Subject")(0))  & Chr(13 ) 

				Call doc.ReplaceItemValue("$KeepPrivate","0")

			End If							    				Set  datadoc = dataview.getnextdocument(datadoc)

		Wend

	Else

		Messagebox("Database couldnot be opened")

	End If

End If



foldername = ""

Forall v In data.Views

	If v.Isfolder Then

		If 	foldername = "" Then

			foldername = v.name

		Else

			foldername = foldername + ",  " + v.name

		End If

	End If

End Forall

Messagebox "Database has " & Cstr(emails) & " Emails ," & Cstr(Attachments) & " Attachments and  "  & Cstr(EncMails) & " Encrypted emails " & Chr(13 ) & foldername , MB_OK, "Status Report" 

If EncMails > 0 Then	

	Messagebox "Database has "  & Cstr(EncMails) & " Encrypted emails " & Chr(13 ) & sPrivateEmails  , MB_OK, "Status Report" 

End If

Print ("Done")

End Sub

Subject: small problem with scipt…object varibable not set

The “” in the getdatabase call means “local machine”. Does the user have this database locally? If not, then use db.Server instead of “”.