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

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?
0
DMills9866
Asked:
DMills9866
  • 2
  • 2
1 Solution
 
Dale FyeCommented:
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
 
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 FyeCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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