The problem being the user is able to switch from form view to other views through shortcuts?
One method, which does something entirely else, is to add a module level boolean variable, which is set to false on load, then only set to true when using your own custom close-button. Perform a check on this variable in the forms on unload event, and cancel that event, if the module level variable isn't true.
[tt]
Private OKToClose as Boolean
Private Sub Form_Load()
OKToClose = False
End Sub
Private Sub TheCustomCloseButton()
OKToClose = True
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not OKToClose Then Cancel = True
End Sub[/tt]
Since changing view will trigger an unload event, this is prevented. It will also prevent users from closing the app/form unless using your custom close button.
Also, where you using mde in stead of mdb, design view would be prevented, then you could just disallow the other views in the forms format properties.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.