Problems stepping through VB code in On Close event with Access 2007 database

Posted on 2011-04-27
Last Modified: 2012-05-11
When the user exits the database (via the frmMainMenu Exit button or hits the X at the upper right corner of the database), I prompt the user with a yes/no question. If they click Yes, I want specific VB code to be processed. I have added this code to frmMainMenu's On Close event. The VB code needs to access controls on frmMainMenu. I am having 2 problems:

1) frmMainMenu closes prior to the prompt being display,  and, as a result, the VB code cannot access the needed controls, since frmMainMenu has closed.
2) I cannot step through the code in the On Close event to make sure that it is working. After clicking Yes from the prompt, it closes the database and does not stop at the break point that I have set.

My questions:
1) How can I prevent frmMainMenu from closing until after the VB processing is complete?
2) How can I step through the On close event code to make sure that it is working correctly?

Question by:newbie46
    LVL 119

    Accepted Solution

    you will need a form that will open first (hidden, always open while app is running) when you open your application. this is where you will place codes to control the closing of your application..

    see this link for the detailed instructions
    LVL 77

    Assisted Solution

    For testing , make sure you have not deselected 'Use Access Special Keys' in Access Options.

    If this option is set and you still can't get the breakpoint to work, select and cut all the code from the relevant module, close and re-open the module and then paste the code back in and compile.  (Make sure you have a backup before doing this)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now