Results 1 to 2 of 2
  1. #1
    Mclaren is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164

    "Are you sure you want to quit Prompt"

    I have the following code attached to my forms Unload event.

    The code works great if the user selects yes when prompted to exit the DB, but the No selection does not work, i get no error, and the DB closes.

    If the user selects no, the form should not close, and no further action should take place. Not sure what i am doing wrong, please assist.

    Code:
    'Ask user if they want to close the session, and act accordingly.
        Select Case MsgBox("Are you sure you Want to Exit ?", vbYesNo, "Warning")
        Case vbYes
            Me.DBSessionClosedDate = Now()
            Me.DBSessionClosed = True
            DoCmd.SelectObject acTable, , True
            ResetWorkspace
            DoCmd.Quit
        Case vbNo
            DoCmd.CancelEvent
            Cancel = True
            Exit Sub
        End Select


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    This works for me:

    Private Sub Form_Unload(Cancel As Integer)
    If MsgBox("Exit?", vbYesNo) = vbNo Then
    Cancel = True
    End If
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  2. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  3. Replies: 13
    Last Post: 07-27-2011, 12:38 PM
  4. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  5. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums