I did not have this before, but recently when I tried to delete documents from a view (select doc and press del button), there was this message saying “Object variable not set”.Strangely, I could still delete the document (a X is shown next to the doc and when F9 was pressed, the doc was subsequently deleted).
I would like to understand how to resolve the “Object variable not set” message.
I put debug on but there was no code execution…
I checked my ondelete event but it is not even called (until I press F9).
Subject: RE: Delete from view - “Object variable not set” error
This is my database Querydocumentdeleteis there a way to supress the error if there are no GetNthDocument(i)?
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
Dim deldoc As NotesDocument
Dim responsedocs As NotesDocumentCollection
Dim session2 As New NotesSession
Dim workspace1 As New NotesUIWorkspace
Dim uidoc2 As NotesUIDocument
Dim doc2 As NotesDocument
Dim itemdoc2 As NotesItem
Dim i As Long
Dim varRoles As Variant
Dim varIndex1 As Variant
varRoles=Evaluate("@UserRoles")
varIndex1=Arraygetindex(varRoles,"[Admin]")
Set uidoc2 = workspace1.CurrentDocument
Set doc2 = uidoc2.Document
Set itemdoc2 = doc2.getfirstitem("AssignmentChangeLog")
'Msgbox Source.Documents.Count & " item(s) marked for deletion"
For i = 1 To source.Documents.Count
Set deldoc = source.Documents.GetNthDocument(i)
itemdoc2.AppendToTextList( deldoc.Resource(0) & " (" & deldoc.hours(0) & "hrs) " & " has been released by: " & session2.CommonUserName )
deldoc.AssignStatus = "Released"
deldoc.Save True, True
'deldoc.Responses.RemoveAll(True)
Next i
uidoc2.Refresh
' Only [Admin] can delete document
If Isnull(varIndex1) Then
Continue = False
Else
deldoc.Responses.RemoveAll(True)
Continue = True
End If
Subject: RE: Delete from view - “Object variable not set” error
I basically have parent - child docs set up, so if parent is gone, the children will need to be deleted.
I also have an embedded view with strange business rules so I added a few code to work around that.
I was requested that when people press “del” key, the embedded doc should not be deleted, rather, a field should be updated (if del was pressed in the embedded view only). For any other view, del should delete the doc…
actually can you please give me a few pointers on how to write decent code? I basically picked up Notes scripts with no background/training (surfed the net and read help).