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

Forcing the user to Exit one way....

Status
Not open for further replies.

csiwa28

Programmer
Apr 12, 2001
177
As of right now a user can exit my document 3 different ways:

(1)Going to File --> Close
(2)'X' out the form on the toolbar
(3)Click on an 'Exit' button.

Is it possible to force/allow the user to exit only one way, by clicking on the 'Exit' button?
 
Is this EXIT button, on a form, or is it a view action?

If it's on a form, I think this would work:

Create a hidden field that you'll be using as a flag field, and set it's Default Value to "0".

On the Post Open of the form, set/reset the flag to "0" (because you'll be setting it with code when exiting the form).

In the script for the Exit button, put code that sets the flag's field value to "1", then performs a close.

In the QueryClose for the form, check the flag. If it's set to "0", Continue = False.

Here's some sample code- I tested it a little, but not completely (didn't try opening and closing a previous form, just tried creating new forms. You might have to work some more code in to error-check and fool-proof.)


{Code for the FORM}:
Sub Postopen(Source As Notesuidocument)
If Source.EditMode Then
Source.FieldSetText "fClose","0"
End If
End Sub

Sub Queryclose(Source As Notesuidocument, Continue As Variant)
If Source.FieldGetText("fClose") = "0" Then
Msgbox "You must use the Close button."
Continue = False
End If
End Sub

------------------------------
{Code for the Exit (or in my case 'Close') button}:
Sub Click(Source As Button)
Dim UIWs As New NotesUIWorkspace
Dim UIDoc As NotesUIDocument
Set UIDoc = UIWs.CurrentDocument
If UIDoc.EditMode = True Then
UIDoc.FieldSetText "fClose", "1"
End If
Call UIDoc.Close
End Sub

---------------------------------
{Properties for Close button}
Default Value: "0"


Good luck, and let me know how it works.
8O)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top