Closing Database Using Quit Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SoNew
    New Member
    • Mar 2008
    • 13

    Closing Database Using Quit Button

    I have designed a database and have used the following code to disable the standard Microsoft close button. I want my users to have to click on a Quit button on the switchboard:

    [CODE=vb]Private Sub Form_Unload(Can cel As Integer)
    Dim LResponse As Integer

    LResponse = MsgBox("Please Use Quit Button on Main Menu", vbOKOnly)
    If LResponse = vbOK Then
    Cancel = True
    End If

    End Sub
    [/CODE]
    They get a pop-up reminder that they have to press OK on - which works well - nothing closes. The problem is that they then get the same reminder when they actually press the Quit button - when the press OK it then closes the database, but I want it to close without having to have this pop-up on the Quit Click.
    Anyone got any code for this?
    Thanks!
    EAC
    Last edited by Stewart Ross; Mar 27 '08, 08:03 PM. Reason: added code tags to VB code
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. The Form_Unload event is raised whenever the form is being closed, so it is correctly fired from your quit routine just as it is after a press of the window close button.

    If you do not want to have the close button on the form then set the form's Close Button property to No. That way you won't have to disable the close at all.

    If you include the close button don't try to bypass it and force users to use your quit button instead - you will just confuse your users. You could always call your quit routine from the form unload or close events so that whatever processing your Quit button does is still done.

    -Stewart

    Comment

    • SoNew
      New Member
      • Mar 2008
      • 13

      #3
      I have disabled the one on the form - it is the actual database close button on the main background page that is the problem (sorry for the lack of technical terms - I don't know access all that well).

      Comment

      Working...