Results 1 to 8 of 8
  1. #1
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214

    Close Button


    Is it possible to have a message box appear when the databases' (not on a form or report) close button is clicked? I want it to say something like "Are you sure you want to exit? yes/no" with the yes button closing the db and the no button returning to main navigation menu.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I don't think can associate code directly with the application close button. Review http://visualbasic.ittoolbox.com/gro...e-event-860153
    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.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Actually, if you load an invisible form first with say the Autoexec macro, it will be the last to close when the user "exits" the application in any manner (other than three finger salute of course). You can use the UnLoad event of this invisible form, which is cancellable, to ask your question and abort the exit.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Hmm...sorry June. I should have followed your link before posting since that is exactly the advice it gave.

  5. #5
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214
    I looked at the link and I'm unable to follow what they are suggesting. Can you tell me what you would put in the Unload event of the form?

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Something like:
    Code:
    Private Sub Form_Unload(Cancel As Integer)
       If MsgBox("Are you sure you want to exit?", vbCritical + vbYesNo) = vbNo Then
          Cancel = True
          DoCmd.OpenForm "YourNavForm"
       End If
    End Sub

  7. #7
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214
    Thank you. That works perfectly.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad we could help.

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

Similar Threads

  1. do NOT save record on close (x button)
    By benjammin in forum Forms
    Replies: 12
    Last Post: 03-15-2013, 02:54 AM
  2. Close Form button not working
    By RedGoneWILD in forum Forms
    Replies: 2
    Last Post: 06-25-2012, 07:02 AM
  3. Disable App Close button in 2007
    By ajetrumpet in forum Programming
    Replies: 3
    Last Post: 09-05-2010, 11:32 PM
  4. Add a close button?
    By thestappa in forum Reports
    Replies: 1
    Last Post: 07-15-2010, 10:43 AM
  5. Close Button Functions
    By Evgeny in forum Programming
    Replies: 3
    Last Post: 04-29-2010, 11:21 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