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

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?

Who is Participating?
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
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
peter57rConnect With a Mentor Commented:
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)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.