Exiting code

  • Thread starter Thread starter Eric G
  • Start date Start date
E

Eric G

I currently have a custom menu with just one drop-down:
File:
Print preview/Print/Close/Exit

After a report is viewed/printed the correct command to use is Close.
But if the admin. mistakenly presses Exit from the drop-down menu the
app closes without certain VB commands being run. In other words, it
seems that when the app Exits, it bypasses the form's OnClose
commands.

How can I, at the same time, protect against the admin from clicking
on the Exit command from the menu, and still have an escape route, to
exit the app.?

I thought about removing the Exit command from the Menu and putting an
Exit button on the main menu (form). Is this a wise way to go? And is
there a way to have VB commands run automatically, as an app Exits?

Thanks Eric
 
Hi Fred,

Thanks for your reply.

It turns out I won't be needing the MsgBox code.
I started by adding an 'x' (allow-close) button for the main form.
This was in preparation for removing Exit from the Menu/File.
I added code to the Main Form's On Close event, to Quit the
application.

But much to my surprise I discovered that the Menu/Close command quits
the app. from Menu Main, and even better, simply closes the form that
calls the report to be printed.
Just what I needed. It closes when called from one form, and quits
when called from the first form (MenuMain).

And now that I've removed Exit from Menu/File, the Admin can't
accidentally select it after printing the report.

On another note. Would you know how to remove Records from showing up
on the top Menu? I just want File to show up, but Records keeps
popping up too.

Eric
 
Back
Top