prevent exiting the database by clicking the 'X'

janeyg

Registered User.
Local time
Today, 19:02
Joined
May 11, 2012
Messages
90
Hi

I would like to prevent the user from closing a userform and exiting the database by clicking the 'X'
on the right side of the titlebar. I need to force closure by using a
command button, and running an exit procedure. I have exit buttons set up on the form but users are ignoring them. Is there a property setting that will prevent this / or run the exit procedure when the 'X' is clicked? I am using acess 2010.
I have found a code (below) but it does not work and other mention using Query close but I cannot find it in the event tab.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "You can't close the dialog like this!"
End If
End Sub


Can anyone help? Much appreciated.
janeyg
 
The stuff you are showing is Excel. In Access you can cancel the Unload event (if some eg. OKtoExit flag was not set by your exit button)
 
ahh. I am new at getting my head around codes. Can you advise what I need to put in this event?
thanks,
 
I could but I won't. The reason is that this is described in the documentation - always the first place to look :D

If you cannot find it, then I can LMGTFY you :D
 
I am not sure which documentation you are referring to. Guess it's easy to find the answers when you know where to look.

I'll keep searching.
 

Users who are viewing this thread

Back
Top Bottom