Access Application Window - how to hide the close button

I am wanting to hide the Close Button on the Access Application Window for the application that I am building.  Does anyone have the code to do this?
DMills9866Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeOwner, Developing Solutions LLCCommented:
What version of Access.  I'm not aware of that being possible, but I don't know about 2010 or 2013.

The way I handle this is that all of my forms contain a Public variable (AllowClose) declared in the declarations section of the forms code module.

The Open event of every form sets that value to False

The Unload event looks like:

Private Sub Form_Unload(Cancel As Integer)

    If AllowClose = False Then
        Cancel = True
        MsgBox "Use the Form -> Close option to close this form"
        Me.Visible = True
    End If
   
End Sub

When you click the Access Applications close button (x) it must first close the active forms.  If the application is unable to close the forms because of this technique, Access itself will not close.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DMills9866Author Commented:
I had found code to gray out the Access Application's close button, so in this design that I have, I will use that methodology.  However, I do like your suggestion above, and will notate that for future projects.

thanks
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
You can disable the close button with the Windows API:

http://support.microsoft.com/kb/300688

Hiding it is another story<g>.

I use the technique Dale suggested and sometimes along with disabling.

However I use a hidden form at startup, called frmGlobal.  This has a check box "OK to close", which get's set by my application exit code (called from the menu, toolbar, etc)
.

  Code in the unload event of frmGlobal makes sure this is set and if not, messages the user and cancels the close.

Since this is the first form opened by the application, it's the first that tries to close, so it catches things early.

Jim.
0
Dale FyeOwner, Developing Solutions LLCCommented:
Jim,

"Since this is the first form opened by the application, it's the first that tries to close, so it catches things early."

I had never really tested that, assuming that the last opened would be the first that Access would try to close.

I was also unaware of the API, so will have to check that out as well.  Any idea whether that works without modification on x64 and Office 64 systems?
0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<I had never really tested that, assuming that the last opened would be the first that Access would try to close.>>

 No.  It goes by the ordnial in the Forms collection.

<<I was also unaware of the API, so will have to check that out as well.  Any idea whether that works without modification on x64 and Office 64 systems? >>

 Both declares need to be updated for 64 bit.

Jim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.