Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2013
    Posts
    46

    Unanswered: Hide Application Close Button Access 2013

    Hi everyone,

    I am new to this forum so please be patient. I am also new to developing Access and would like to hide the application close/min/max so the user is forced to select the button for Quit Application on my main form. I have tried numerous ways but none have seemed to work with Access 2013 or I am not programming correctly. I had the following procedure working at one time but now it isn't.

    I appreciate any help you can offer,
    Bill

    I tried this procedure is to disable the Min/Max/Close on application.

    Copy the following into a new module:
    Code:

    Option Compare Database
    Option Explicit


    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 HideAccessCloseButton()
    Dim lngStyle As Long
    lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
    lngStyle = lngStyle And Not 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

    Then from my main forms on load event call it with:
    Code:
    'Call module to hide access application close button
    HideAccessCloseButton
    Last edited by billgyrotech; 07-19-13 at 13:44. Reason: Adding the code

  2. #2
    Join Date
    Jan 2005
    Posts
    146
    If you have some VBA code you would like to run that is behind your button, put a reference to the procedure in your forms On Close event and it will still fire regardless of how Access is closed, the only problem is you can't stop Access from closing.

    With regards to your function, if your running a new version of windows (7 or 8) it may no longer like your code, check this out.

    SetWindowLong function (Windows)

  3. #3
    Join Date
    Jul 2013
    Posts
    46
    I am using windows 7. I looked at the link but code is very confusing to me.

  4. #4
    Join Date
    Jan 2005
    Posts
    146
    Me too, controlling the Access window has always been a difficult task.

  5. #5
    Join Date
    Jul 2013
    Posts
    46
    I had this code working this morning but now it isn't. I really don't know what went wrong.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Bill

    I received your message. I am afraid I have not used Access for something like four-five years now. So yes I used to do this, but I have not idea how and have no sample code knocking around.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Jul 2013
    Posts
    46

    Disable Application Close Button Access 2013

    Thanks for the reply. For some reason the code that I posted is working now. Is there a way to post this in the code area so others could benefit?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •