Titlebar Close Button handling

  • Thread starter Thread starter Boss
  • Start date Start date
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?
 
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.
 
Back
Top