Stopping unauthorised program exit

N

Neil Warwick

In my application I have a form that has some data
validation on it which is done when the user presses a
button to exit the form.
To stop the user from exiting the form illegally I have
disabled the close window icon in the top right of the
window, however the users are still able to exit the
application and form and bypass the error checking by
hitting the close application icon in the top right of the
main access window.

Is there any way I can also disable this button so that it
is impossible to leave the form until all data is valid?

Thanks

Neil
 
T

Tony C

If you use the Forms "On Unload" Procedure, you can
control if it is ok to quit/close down the form: -

Try adding the following code: -

Dim CheckData As Boolean
Dim MsgValue
'For each field repeat this code: -
If Me.Field01= "Blah Blah" Then CheckDataOK=True Else
CheckDataOK=False
If CheckDataOK=False Then Cancel=True Else Cancel=False
If Cancel = True Then msgvalue=msgBox("Submitted data does
not comply with data restrictions, check
data.",vbokcancel+vbinformation)
'End Of Code

HTH


Tony C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top