Titlebar Close Button handling

B

Boss

Hey everybody. My database when it starts up hides the Access container
window from the user completely through the winapi. My superiors want
the close button to remain on all the forms but if you click that, the
form is closed, and MSACCESS.EXE is left running in the system memory.
How can I, through vba, tell when that button is clicked and run a
docmd.quit instead of just having the form hidden like normal behavior.

Is this possible in VBA?
 
A

Allen Browne

You could use the Close event of the form to test Forms.Count and
Reports.Count.

If Forms.Count =1 and Reports.Count = 0, you are closing the last form, and
so you can DoCmd.Quit.

If some forms/reports could be hidden, you would need to loop through the
Forms and Reports collection to see if there are any visible ones.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top