in the action Edit Document
ENVIRONMENT flag := "1";
you can control user access to action using "hide action if formula true"
Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
Dim ses As New notessession
If flag <> "1" Then
Messagebox "Use Edit Document action", 0, "Action Error"