Object Variable not set

I have code written in PostDocumentDelete which works fine until it comes across ForAll statement and gives error as “Object variable not set” while runtime. I tried with declaring “i” with Dim also. All the used variables here are declared in Declarations section. Also the same ForAll loop works fine in PostSave event.

Any ideas? If anyone could help, will be appreciable.

Thanks in advance

Sub Postdocumentdelete(Source As Notesuidatabase)

Dim Modcal_Mgxml As String

Dim Modcal_MgxmllOOP As String

Dim Modcal_MgRTitem As Variant

Dim Modcal_MgCnt As Integer

Modcal_MgCnt=0

Set Modcal_MgDatabase = source.Database

Set Modcal_MgSession = Modcal_MgDatabase.Parent

Modcal_MgNotesUser = Modcal_MgSession.UserName

Modcal_MgNotesServer=Modcal_MgDatabase.Server

Modcal_MgNotesFileName=Modcal_MgDatabase.FilePath

Modcal_MgMffPath= “1-%ifclib%domino%sl%dominoifc.ecf”

Modcal_MgPrgName = “2-Modcal”

Modcal_Mgxml=“”

Modcal_Mgxml=Modcal_Mgxml+{} + Chr(13)

Modcal_Mgxml=Modcal_Mgxml + “Delete”

Forall i In Modcal_MgDocument.items

If Instr(Modcal_MgIncludeList,i.name) Then

Modcal_MgxmllOOP = Modcal_MgxmllOOP + “<” + i.name + “>” + i.text + “</” + i.name + “>” + Chr(13)

End If

End Forall

Modcal_Mgxml = Modcal_Mgxml + Modcal_Mgxmlloop

Modcal_Mgxml = Modcal_Mgxml + {}

End Sub

Subject: Object Variable not set

I haven’t seen the code to set “Modcal_MgDocument” instance. Without setting reference to the notesdocument you cannot loop through all the field/items.

Try to set document handle to “Modcal_MgDocument”.

–Phani

Subject: Object Variable not set

Mandar,

Is this all of the code? It looks like the object Modcal_MgDocument hasn’t been declared or set.

Subject: RE: Object Variable not set

Hi Familyguy and kiran,As I written I have already declared the Modcal_MgDocument as NotesDocument in Global Declarations.

And I have set it in QueryDocumentDelete as

Set Modcal_MgDocument = Modcal_MgDocs.GetFirstDocument

Subject: RE: Object Variable not set

Can you verify using the debugger whether the “Modcal_MgDocs” object is set and initialized when it reaches the “ForAll” loop.

–Phani