Object Variable not set

Dear all expert,

Can you kindly help me to look into this code where I have an error Object Variable Not Set, my script is as below:

Sub Initialize

Dim session As New NotesSession

Dim doc As NotesDocument

Dim db As NotesDatabase

Dim view As NotesView

Set db = session.currentdatabase

Set doc = New notesdocument(db)

Set doc = session.DocumentContext

Set db = session.CurrentDatabase

Dim newDoc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim thisdoc As NotesDocument

Dim item As notesitem

Dim dateTime As New NotesDateTime( “” ) dateTime.LSLocalTime = Now

varA = doc.zTempDate(0)

varB = doc.zTempDescription(0)

varC = doc.Reason(0)

varD = doc.zTempRoute(0)

'Reminder

Dim weekDateTime As NotesDateTime

Dim modifiedDateTime As NotesDateTime

Set db = session.CurrentDatabase

Set doc = session.DocumentContext

Set weekDateTime = New NotesDateTime( “Today” )

Set modifiedDateTime = New NotesDateTime( “” )

Call weekDateTime.AdjustDay( -2 ) ’ set to one week ago

modifiedDateTime.LSLocalTime = doc.LastModified

If weekDateTime.TimeDifferenceDouble( modifiedDateTime ) > 0 Then

Set newDoc = New NotesDocument( db )

newDoc.Form = “Memo”

newDoc.Subject = “Reminder: please update your Decision”

Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))

Call newDoc.Send( False, doc.zTempRoute )

End If

If doc.Approval(0)=“Approve” Then

zTempSign = “Department Head:” + Chr(9) + Chr(9) + varD + " (" + dateTime.DateOnly + ", " + dateTime.TimeOnly + “) - Approved” + Chr(10) + Chr(10)

Set item = doc.GetFirstItem(“zSign”)

Call item.AppendToTextList(zTempSign)

Set newDoc = New NotesDocument( db )

Set rtitem = New NotesRichTextItem( newDoc, “Body” )

Call rtitem.appendtext(“Please be informed that the following form is seeking for your approval.” + Chr(10) + Chr(10) + “Please click on the icon below for your perusal.”+Chr(10)+Chr(10))

Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))

newDoc.Subject = “E - Signboard Application : Marketing Verification” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)

newDoc.SendTo = doc.GetItemValue(“zSBMktg”)

newDoc.Send( False )

Set newDoc = New NotesDocument( db )

Set rtitem = New NotesRichTextItem( newDoc, “Body” )

Call rtitem.appendtext(“Please be informed that the following form has been approved by Department Head.” + Chr(10) + Chr(10) +"Date: " + varA + Chr(10) + Chr(10) )

'Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))

newDoc.Subject = “Notification upon Regional Manager Approval” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)

newDoc.SendTo = doc.GetItemValue(“zRequestBy”)

newDoc.Send( False )

Print “

E - Signboard Application Approval Process has been Updated

End If

If doc.Approval(0) = “Reject” Then

varA = doc.zTempDate(0)

varB = doc.zTempDescription(0)

varC = doc.Reason(0)

varD = doc.zTempRoute(0)

zTempSign = “Department Head:” + Chr(9) + Chr(9) + varD + " (" + dateTime.DateOnly + ", " + dateTime.TimeOnly + “) - Rejected” + Chr(10) + Chr(10)

Set item = doc.GetFirstItem(“zSign”)

Call item.AppendToTextList(zTempSign)

Set newDoc = New NotesDocument( db )

Set rtitem = New NotesRichTextItem( newDoc, “Body” )

Call rtitem.appendtext(“Please be informed that the following service request has been rejected by department head.” + Chr(10) + Chr(10) + " Date: " + varA + Chr(10) + Chr(10))

Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))

newDoc.Subject = “Notification upon Rejected Request for E - Signboard Application Rejected” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)

newDoc.SendTo = doc.GetItemValue(“zRequestBy”)

newDoc.Send( False )

Print “

E - Signboard Application Approval Process has been Updated

End If

If doc.Approval(0) = “Route Back” Then

varA = doc.zTempDate(0)

varB = doc.zTempDescription(0)

varC = doc.Reason(0)

varD = doc.zTempRoute(0)

zTempSign = “Department Head:” + Chr(9) + Chr(9) + varD + " (" + dateTime.DateOnly + ", " + dateTime.TimeOnly + “) - Route Back” + Chr(10)+ Chr(10)

Set item = doc.GetFirstItem(“zSign”)

Call item.AppendToTextList(zTempSign)

Set newDoc = New NotesDocument( db )

Set rtitem = New NotesRichTextItem( newDoc, “Body” )

Call rtitem.appendtext(“Please be informed that the following service request has been Route Back by department head.” + Chr(10) + Chr(10) + " Date: " + varA + Chr(10) + Chr(10))

Call rtitem.AppendDocLink(doc, “Click here to open the document”+Cstr(Today))

newDoc.Subject = “Notification upon E - Signboard Application Route Back” + Chr(9)+ “-” + Chr(9)+ doc.zSBTitle(0)

newDoc.SendTo = doc.GetItemValue(“zRequestBy”)

newDoc.Send( False )

Print “

E - Signboard Application Approval Process has been Updated

End If

End Sub

Subject: Object Variable not set

You should be able to use the debugger to identify the statement where this error is occurring. I don’t think anyone on this forum is going to wade through all that code to see where it might be happening.

Subject: Object Variable not set

In addition to what Wayne said, you could also put in an error trapping routine and let it tell you what line is getting the error.

Subject: RE: Object Variable not set

Thank you so much for the responses.

I had partially solved the reminder but there is some problem,

Where I scheduled the agent to run every 10 minutes, target to All new & Modified documents.

But it never run as per scheduled. It only run when I Run the agent manually or refresh the database design.

Can you kindly please advice me on this?

Thank you.

Subject: RE: Object Variable not set

Hi,

Check if the agent signer has access to run the agent in server. Open log.nsf in server, to see the cause of agent not running. If you are sure of one user ID, having access to the agent. Mention the user’s full hierarchial name in the run on behalf of - property. Hope, this helps somewhat