How to trap when Access is closed

J

Jerry

Does anyone know how to trap when a user click's the x on
an Access mde? I need to insert code to either trap it
and issue a message or if there is a way to hide the
max,min and close on Access.

Thanks in advance for any assistance

Jerry
 
E

Elwin

If you're using a form you could place some code into the
Unload event that checks a module level variable
maintained by your close button. If the variable isn't
set you could set Cancel = True in your unload event to
stop the application from closing.

Dim bolOKToClose as Boolean

Private Sub Form_Open()
bolOKToClose = False
End Sub

Private Sub cmdClose_Click()
bolOKToClose = True
DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_Unload(Cancel as Integer)
If bolOKToClose Then
DoCmd.Quit
Else
MsgBox "Use the Close button",vbInformation,"Alert"
End If
End Sub
 

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