[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

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?

2 Solutions
Rey Obrero (Capricorn1)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

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)


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now