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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent document editing using Queryopen event 1

Status
Not open for further replies.

sstewa22

Technical User
Oct 12, 2004
2
US
thread73-1342849

I'm trying to prevent a user from editing a document that has a field set to "Completed" using Queryopen event. I'm new at this and need help with the coding. I found this code, but it is not working, I don't know how to set the Source.Document.Status?

Code:
Sub Queryopen(Source As
Notesuidocument, Mode As Integer,
Isnewdoc As
Variant, Continue As Variant)
If mode and not IsNewDoc Then
If Source.Document.Status(0) = "Closed"
Then
Messagebox "You may not edit a
closed document."
continue = False
End If
End If
End Sub

Is there a way to do prevent document editing with a View instead?
My goal is prevent users modifying a document after it has been set as completed. Maybe there is a way to set the acl for a view to read only?
 
Source.Document.Status(0) refers to the field named "Status" in the document.
This field can be an explicit part of the design of the form (meaning, a field in the design of the form), or a field created by script during the existence of the document.

What you need to understand is that there are two ways of controlling document edition - either in the form, or in the view.
If you control editing in the form, that control will be effective for all documents based on said form, whatever the view they are listed in.
If you control editing from the view, you will essentially be locking down the documents in the view and preventing them from being editable, but in that view only.

Apparently, you wish to lock down documents that are "completed". Do these documents appear only in views that detail "completed" documents ? Or do completed documents appear in views alongside non-completed documents ?

If completed docs only appear without non-completed documents, then you could forego changing the form and use the Queryopendocument event to lock out all edits.
Otherwise, you'll need to modify the QueryModeChange event of the form design.

Pascal.

I've got nothing to hide, and I'd very much like to keep that away from prying eyes.
 
Thank you Pascal for the quick answer. I was able to code the form to prevent editing based on the text in the status field. I then created an agent to change the document back for editing just in case.

Thank you again!
Sherril
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top