MS Access 2003: Unhide Close button on Access program
This MSAccess tutorial explains how to display the close button for the Access program when it has been hidden in Access 2003 (with screenshots and step-by-step instructions).
Question: In Microsoft Access 2003/XP/2000/97, I've disabled the Close button on the Access program. How can I re-enable it?
Answer: You can re-enable the Close button on the Access program using VBA code.
Open your Access database, click on the Modules tab and create a new Module. Paste in the following code:
Private Const GWL_EXSTYLE = (-20) Private Const GWL_STYLE = (-16) Private Const WS_MAXIMIZEBOX = &H10000 Private Const WS_MINIMIZEBOX = &H20000 Private Const WS_SYSMENU = &H80000 Private Const HWND_TOP = 0 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOSIZE = &H1 Private Const SWP_FRAMECHANGED = &H20 Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED Private Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long, ByVal dwNewLong As Long) _ As Long Private Declare Function GetWindowLong Lib "user32" _ Alias "GetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long) As Long Private Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _ ByVal x As Long, ByVal y As Long, ByVal cx As Long, _ ByVal cy As Long, ByVal wFlags As Long) As Long Sub UnHideAccessCloseButton() Dim lngStyle As Long lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE) lngStyle = lngStyle Or WS_SYSMENU Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle) Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME) End Sub
Now when you view your Access program, you can see that the close button in the top right corner is not visible.
Now, execute the following VBA code:
Private Sub Command0_Click() UnhideAccessCloseButton End Sub
Now, when you view your Access program, the Close button in the top right corner will be visible again.
This MSAccess tutorial explains how to Hide the Close button on an Access program.
Advertisements