How to trap when Access is closed

  • Thread starter Thread starter Jerry
  • Start date Start date
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
 
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
 
Back
Top