Results 1 to 11 of 11
  1. #1
    Uudistaja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    6

    Confirming closing database


    Hello, I need to create a button which when pressed will close currently active database, but before closing I need it to ask if I am sure or to go back to the form.

    How can I do that?

  2. #2
    vdanelia is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    38
    Hello.. Put this VBA on Command Button's On Click Event

    If MsgBox("Are you sure?", vbYesNo + vbQuestion) = vbYes Then
    DoCmd.Close
    Else
    'Something Function if you want to add
    End If
    Last edited by vdanelia; 03-01-2011 at 02:02 PM. Reason: Misstyped

  3. #3
    Uudistaja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    6
    This one closes the form when clicked Yes or No. I need it to close database, if clicked yes. And if clicked No I need it to ignore the click on button.

  4. #4
    vdanelia is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    38
    I edited the code below, I miss typed, Try this.... if something wrong post

  5. #5
    Uudistaja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    6
    DoCmd.Close - this line closes the form, can you edit this, so that it closes the database? I dont know the function name :/

  6. #6
    vdanelia is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    38
    Explain first, What do you want to close, table or form (What do you mean database) you want to exit from the access?

  7. #7
    Uudistaja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    6
    I want it to exit from the current active database, so that when I click Yes, it closes the database I am using currently.

  8. #8
    vdanelia is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    38
    Try this DoCmd.Quit acQuitPrompt

  9. #9
    Uudistaja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    6
    This one closes Access aswell, I just need it to close the database I am working with :P. I believe there is a macro built-in to access for it also.

  10. #10
    vdanelia is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    38
    ahhhhh I guessed what you neeed
    Use this.. will work

    DoCmd.CloseDatabase

  11. #11
    Uudistaja is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    6
    Yes, that did it. Thanks a lot!

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

Similar Threads

  1. Question about confirming delete record operation.
    By tdanko128 in forum Programming
    Replies: 1
    Last Post: 02-09-2011, 09:16 AM
  2. Closing a form through VBA
    By ghostmachine in forum Forms
    Replies: 4
    Last Post: 12-13-2010, 01:57 PM
  3. Closing a combo box
    By Remster in forum Forms
    Replies: 5
    Last Post: 11-30-2010, 04:54 AM
  4. Replies: 1
    Last Post: 03-24-2010, 08:48 AM
  5. Compacting When Closing?
    By Sean04 in forum Access
    Replies: 5
    Last Post: 03-19-2010, 01:16 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