Set docParent = db.GetDocumentByUNID(docCollection1.GetItemValue(“$Ref”)(0))If Not docParent Is Nothing Then
Call collection1.DeleteDocument(docCollection1)
End If
Any ideas why this does not work
Set docParent = db.GetDocumentByUNID(docCollection1.GetItemValue(“$Ref”)(0))If Not docParent Is Nothing Then
Call collection1.DeleteDocument(docCollection1)
End If
Any ideas why this does not work
Subject: Deleting from a collection
Are you trying to delete the document from the collection or from the disk?
Subject: RE: Deleting from a collection
i am just trying to delete it from the collection. I am trying to remove all responses from a collection
Subject: RE: Deleting from a collection
Not sure if this applies in your case (you did not post the code of how you obtained a reference to docCollection1). From Designer Help:
Usage
The specified document must have originated in this collection. If the document does not exist in the collection, or if it was removed from the database by a RemoveAll operation, an error will be raised.
Do you get an error or does the document continue to exist in the collection?
Subject: RE: Deleting from a collection
Full Code
Set docCollection1 = collection1.GetFirstDocument
Set docNext = collection1.GetNextDocument(docCollection1)
Do While Not ( docCollection1 Is Nothing)
Select Case DocCollection1.form(0)
Case “Base Packaging”,“Base Raw Material”,“Finished Product”,“Packaging”,“Raw Material”,“Report Header”
Case Else
Set docParent = db.GetDocumentByUNID (docCollection1.GetItemValue(“$Ref”)(0))
If Not docParent Is Nothing Then
Call collection1.DeleteDocument(docCollection1)
End If
End Select
If docNext Is Nothing Then
Exit Do
Else
Set docCollection1 = docNext
End If
Loop
Return
Subject: RE: Deleting from a collection
It may be that you’ve got your set docnext in the wrong place.
You’ll never loop through all the documents as there’s no getnextdocument within the loop.
Put the set docNext line after the Do While line and see what happens
Subject: RE: Deleting from a collection
It still aint working. Code as it stands now. I add a line as suggested to set Doctemp to be the document being removed from the collection and it gets seeded
RemoveResponses:
'This sub routine takes what the user has selected and removes any response document whos
'parent document is present in the documnets selected
Set docCollection1 = collection1.GetFirstDocument
Set docNext = collection1.GetNextDocument(docCollection1)
Do While Not ( docCollection1 Is Nothing)
Set docNext = collection1.GetNextDocument(docCollection1)
Select Case DocCollection1.form(0)
Case "Base Packaging","Base Raw Material","Finished Product","Packaging","Raw Material","Report Header"
Case Else
Set docParent = db.GetDocumentByUNID(docCollection1.GetItemValue("$Ref")(0))
If Not docParent Is Nothing Then
Call collection1.DeleteDocument(docCollection1)
End If
End Select
If docNext Is Nothing Then
Exit Do
Else
Set docCollection1 = docNext
End If
Loop
Return
Subject: RE: Deleting from a collection
Do you get an error or does the document continue to exist in the collection?
Subject: RE: Deleting from a collection
No error. It appears to remain in the collection. In thescript debugger the count number stays the same before and after the Call to deletethedocument from the collection.
Subject: RE: Deleting from a collection
OK - it may be that the count is not updated. I recall having an issue where count is inaccurate under certain circumstances. What happens if you try to get the document from the collection again? For example:
Set docCollection1 = collection1.GetFirstDocument
Set docNext = collection1.GetNextDocument(docCollection1)
Do While Not ( docCollection1 Is Nothing)
Select Case DocCollection1.form(0)
Case “Base Packaging”,“Base Raw Material”,“Finished Product”,“Packaging”,“Raw Material”,“Report Header”
Case Else
Set docParent = db.GetDocumentByUNID (docCollection1.GetItemValue(“$Ref”)(0))
If Not docParent Is Nothing Then
Call collection1.DeleteDocument(docCollection1)
Set docTemp = collection1.GetDocument(docCollection1) 'Any error on this line?
End If
End Select
If docNext Is Nothing Then
Exit Do
Else
Set docCollection1 = docNext
End If
Loop
Return
Subject: RE: Deleting from a collection
It is being caused by not setting the docnext after the first case statement - DOH. Thanks for your help and assistance