none
Disable the Maximize button for Access (NOT FORM) RRS feed

  • Question

  • Hey all, I am setting up a database where only the form is accessible to the users. 

    I have hidden the navigation and have hidden the ribbon.

    I set the form to have no boarder. So the users can activate some buttons and close access. Thats all.

    So I set the window in Access to match the size of the foam. I dont want them maximizing access.

    I have a 64 bit machine... So please dont give me 32-bit API code


    Saturday, September 5, 2015 7:31 PM

Answers

  • I think I got a better way

    modal = true
    popup = true.
    boarder = none

    make the access window very tiny and center to screen..

    Close access, reopen access. The access window is permanently stuck behind the form.

    There is a button on the form to close Access.

    Like I said, the access window is permanently stuck behind the form, you cannot access anything in accces or even ctrl+w, so If you truly need back in Access, open it holding SHIFT.

    Edit: You can turn dialog on and move the super tiny access window above the system clock.

    When you open Access, the form will open in it's last location. So it's like having a stand alone form application



    Saturday, September 5, 2015 8:21 PM

  • No, I'm looking to get rid of the maximize button. Thats because I was manually re-sizing access to match the form.

    Ahh, got it. Thanks for the clarification.

    I think I'm finally more resolved.

    I got the code that wasnt working for 64-bit to work by adding "PtrSafe"

    Here is how it's done

    Option Compare Database 
    Option Explicit 
     
    Global Const SW_HIDE = 0 
    Global Const SW_SHOWNORMAL = 1 
    Global Const SW_SHOWMINIMIZED = 2 
    Global Const SW_SHOWMAXIMIZED = 3 
     
    Private Declare PtrSafe Function apiShowWindow Lib "user32" _ 
    Alias "ShowWindow" (ByVal hWnd As Long, _ 
    ByVal nCmdShow As Long) As Long 
     
    Function fSetAccessWindow(nCmdShow As Long) 
         
        Dim loX As Long 
        Dim loForm As Form 
        On Error Resume Next 
        Set loForm = Screen.ActiveForm 
         
        If Err <> 0 Then 
            loX = apiShowWindow(hWndAccessApp, nCmdShow) 
            Err.Clear 
        End If 
         
        If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then 
            MsgBox "Cannot minimize Access with " _ 
            & (loForm.Caption + " ") _ 
            & "form on screen" 
        ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then 
            MsgBox "Cannot hide Access with " _ 
            & (loForm.Caption + " ") _ 
            & "form on screen" 
        Else 
            loX = apiShowWindow(hWndAccessApp, nCmdShow) 
        End If 
        fSetAccessWindow = (loX <> 0) 
    End Function

    Then put this in the onload for the form

    fSetAccessWindow(SW_SHOWMINIMIZED)



    Saturday, September 5, 2015 10:54 PM

All replies

  • By "64-bit machine" I assume that you mean 64-bit Windows. But do you have 64-bit Access? Most users have 32-bit Access even on 64-bit Windows. To check, click File > Account, then click About Access.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Saturday, September 5, 2015 7:45 PM
  • I have 2013. its 64 bit only...

    And the fact I said dont give me 32 bit API code implies that the only code I can find doesnt work because of my 64bit

    Saturday, September 5, 2015 7:54 PM
  • I think I got a better way

    modal = true
    popup = true.
    boarder = none

    make the access window very tiny and center to screen..

    Close access, reopen access. The access window is permanently stuck behind the form.

    There is a button on the form to close Access.

    Like I said, the access window is permanently stuck behind the form, you cannot access anything in accces or even ctrl+w, so If you truly need back in Access, open it holding SHIFT.

    Edit: You can turn dialog on and move the super tiny access window above the system clock.

    When you open Access, the form will open in it's last location. So it's like having a stand alone form application



    Saturday, September 5, 2015 8:21 PM
  • Hi. Nice solution. But doesn't that affect all other database used on the same system? For example, if someone opens another database file and maximize the Access window before closing it, wouldn't the Access window still show up when you open your database file? Just curious... (I can't test it right now.)
    Saturday, September 5, 2015 8:39 PM
  • Hi. Nice solution. But doesn't that affect all other database used on the same system? For example, if someone opens another database file and maximize the Access window before closing it, wouldn't the Access window still show up when you open your database file? Just curious... (I can't test it right now.)

    I would assume you're correct.

    The database I'm setting up will be the only database this company uses, at least on that specific PC.

    EDIT:

    I assume it would be easier to get software to manually shrink the access window if needed then to write API inside access



    Saturday, September 5, 2015 8:50 PM
  • Hi. If the whole purpose is to just avoid "closing" Access through the red X button without going through your own "close" button, then you won't need any API for that. You should be able to implement something within Access that if the user clicks on the red X button on the Access window, it won't close your database. Is that what you wanted?
    Saturday, September 5, 2015 9:05 PM
  • Hi. If the whole purpose is to just avoid "closing" Access through the red X button without going through your own "close" button, then you won't need any API for that. You should be able to implement something within Access that if the user clicks on the red X button on the Access window, it won't close your database. Is that what you wanted?
    No, I'm looking to get rid of the maximize button. Thats because I was manually re-sizing access to match the form.
    Saturday, September 5, 2015 9:41 PM

  • No, I'm looking to get rid of the maximize button. Thats because I was manually re-sizing access to match the form.
    Ahh, got it. Thanks for the clarification.
    Saturday, September 5, 2015 9:59 PM

  • No, I'm looking to get rid of the maximize button. Thats because I was manually re-sizing access to match the form.

    Ahh, got it. Thanks for the clarification.

    I think I'm finally more resolved.

    I got the code that wasnt working for 64-bit to work by adding "PtrSafe"

    Here is how it's done

    Option Compare Database 
    Option Explicit 
     
    Global Const SW_HIDE = 0 
    Global Const SW_SHOWNORMAL = 1 
    Global Const SW_SHOWMINIMIZED = 2 
    Global Const SW_SHOWMAXIMIZED = 3 
     
    Private Declare PtrSafe Function apiShowWindow Lib "user32" _ 
    Alias "ShowWindow" (ByVal hWnd As Long, _ 
    ByVal nCmdShow As Long) As Long 
     
    Function fSetAccessWindow(nCmdShow As Long) 
         
        Dim loX As Long 
        Dim loForm As Form 
        On Error Resume Next 
        Set loForm = Screen.ActiveForm 
         
        If Err <> 0 Then 
            loX = apiShowWindow(hWndAccessApp, nCmdShow) 
            Err.Clear 
        End If 
         
        If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then 
            MsgBox "Cannot minimize Access with " _ 
            & (loForm.Caption + " ") _ 
            & "form on screen" 
        ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then 
            MsgBox "Cannot hide Access with " _ 
            & (loForm.Caption + " ") _ 
            & "form on screen" 
        Else 
            loX = apiShowWindow(hWndAccessApp, nCmdShow) 
        End If 
        fSetAccessWindow = (loX <> 0) 
    End Function

    Then put this in the onload for the form

    fSetAccessWindow(SW_SHOWMINIMIZED)



    Saturday, September 5, 2015 10:54 PM
  • Hi Joseph. Congratulations on finding a solution that work for you. But if you want to be "safer," you should declare the hWind object as a LongPtr too. For example:

    Private Declare PtrSafe Function ShowWindow Lib "user32" ( _
       ByVal hWnd As LongPtr, _
       ByVal nCmdShow As Long _
    ) As Boolean

    Cheers!

    Sunday, September 6, 2015 2:53 PM