Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Open Mail

Status
Not open for further replies.

Shoot

Programmer
Oct 11, 2003
31
US
Hi
I am new to Lotus Notes.
I am writing code in a button. Once the code is executed or action is performed, I need to close and Delete the Current Mail Document.

I am trying to use this code..
Call Workspace.CurrentDocument.Document.Remove(1)

It throws an error message saying "Cannot Remove NotesDocument when instantiated by NotesUIDocument"

Any thoughts or ideas in this regard would be more helpful.

Keep Smiling,
Shoot
 
I would suggest creating a Notesdocument object and assigning the backend to it, then closing the UI instance, then deleting the backend.
Something like this :
Code:
Dim UIdoc AS NotesUIdocument
Dim Doc AS NotesDocument

Set UIdoc = Workspace.CurrentDocument
Set Doc = UIdoc.Document
...
Call UIdoc.Close
Call Doc.Remove(True)
That way, you'll remove the link between the UI and the backend, and that should help in removing the error.

Pascal.
 
Hi Pascal,
I tried using it but it doesn't solve the problem. I still get the same error. Any other suggestions?

Keep Smiling,
Shoot
 
hey there,

I reported the same problem a few days ago:
try to refresh design on the template and then make a fixup.

should help,
sue.
 
If you still cannot get it to work, I'd suggest a workaround.
Make a hidden view called "(deleteDocs)" (or similar). Set the Selection formula to
Code:
SELECT DeleteDoc="YES"
Then create and agent that opens that view in the backend and deletes all docs in it.

Then, take your original code and, instead of trying to delete docs, just set a new field DeleteDoc to "YES".
Finally, at the end of the original script, tell it to launch the delete script.

Rather long-winded result, but it should work like that.

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top