Hi,
I am writing an agent to archive old documents in a database. Everything is working fine until I try to delete the document that has been processed. I know its to do with where I have the line of code "Call doc.Remove( True )" placed because the agent is working as it should (without deleting the doc of course) when I don't have this line "Call doc.Remove (True)" in the script.
Basically what I want the script to do is:
1) Get first doc in view
2) If AStatus field is "Live", move subforms to archive db
3) Move main form to archive db
4) delete the doc from the db
5) get next doc in view and then back to 2)
Here a shortened version of the code:
' get the first document
Set doc = v.GetFirstDocument
Do While Not (doc Is Nothing)
' get the status of the reord
Select Case doc.AStatus(0)
' if astatus live
Case "Live"
/////////////// archive document code ////////////////////
End Select
Call doc.CopyToDatabase(archivedb)
****************here I want to remove the document that is after been archived but I am getting an error *************
Call doc.Remove( True )
Set doc = v.GetNextDocument (doc)
Loop
Any help would be greatly appreciated.
Kind regards,
Kenneth
I am writing an agent to archive old documents in a database. Everything is working fine until I try to delete the document that has been processed. I know its to do with where I have the line of code "Call doc.Remove( True )" placed because the agent is working as it should (without deleting the doc of course) when I don't have this line "Call doc.Remove (True)" in the script.
Basically what I want the script to do is:
1) Get first doc in view
2) If AStatus field is "Live", move subforms to archive db
3) Move main form to archive db
4) delete the doc from the db
5) get next doc in view and then back to 2)
Here a shortened version of the code:
' get the first document
Set doc = v.GetFirstDocument
Do While Not (doc Is Nothing)
' get the status of the reord
Select Case doc.AStatus(0)
' if astatus live
Case "Live"
/////////////// archive document code ////////////////////
End Select
Call doc.CopyToDatabase(archivedb)
****************here I want to remove the document that is after been archived but I am getting an error *************
Call doc.Remove( True )
Set doc = v.GetNextDocument (doc)
Loop
Any help would be greatly appreciated.
Kind regards,
Kenneth