Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove the application close button posibble? 1

Status
Not open for further replies.

ad2

Technical User
Dec 31, 2002
186
US
Hi,

I have an Access 2003 application. The manager wants the default Close(x) and min and max buttons disabled or not displayed, so that the data entry persons will be forced to close the application via a button.

Well, I've unchecked the boxes under Tools and Startup, and set the Form properties for these to no. But the X and min/max for the Microsoft Access application itself are still available.

Anyone know how to remove these?

Thanks,
AD2
 
I don't have experience with Access 2003 but this works in 97. Create a new module and copy in the following. Then in the On Open event of your opening form call it.

Option Explicit

Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal brevert As Long) As Long

Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As _
Long, ByVal wIDenableItem As Long, ByVal wenable As Long) As Long

Const MF_Grayed = &H1&
Const MF_BYCOMMAND = &H0&
Const SC_CLOSE = &HF060&

'Disable the Close Button Option
Sub CloseButtonState(boolClose As Boolean)

Dim hWnd As Long
Dim wFlags As Long
Dim hMenu As Long
Dim result As Long

hWnd = Application.hWndAccessApp
hMenu = GetSystemMenu(hWnd, 0)
If Not boolClose Then
wFlags = MF_BYCOMMAND Or MF_Grayed
Else
wFlags = MF_BYCOMMAND And Not MF_Grayed
End If

result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)

End Sub


 
Hi Bubba100,

I created the new module. I put this on the onOpen event:

=CloseButtonState()

but it didn't work, the title bar with the close button is still active.
 
You should use the event procedure:
Call CloseButtonState(False)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks Bubba100 for the great code and to PHV for the tip on implementation. Works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top