Results 1 to 5 of 5
  1. #1
    jcc285 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    70

    Access 2013 - Hiding and Showing Access Window

    I am trying to Hide or Show the Access Window by using two buttons on a Form. Running Access 2013 in Windows 7 64bit.

    I have used code from the Internet as below but added the PtrSafe item to the Function Declaration as below:-
    Option Compare Database
    'Hide Access desktop screen and float Forms on pc desktop
    Private Declare PtrSafe Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long

    Dim dwReturn As Long
    Const SW_HIDE = 0
    Const SW_SHOWNORMAL = 1
    Const SW_SHOWMINIMIZED = 2
    Const SW_SHOWMAXIMIZED = 3

    Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

    Public Function fSetAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
    'Controls wheter or not the Access Desktop Screen is visible
    'In Form Code use Call fSetAccessWindow("Minimize", False, False)
    If Procedure = "Hide" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    End If
    If Procedure = "Show" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
    If Procedure = "Minimize" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
    End If
    If SwitchStatus = True Then
    If IsWindowVisible(hWndAccessApp) = 1 Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    Else
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
    End If
    If StatusCheck = True Then

    If IsWindowVisible(hWndAccessApp) = 0 Then
    fSetAccessWindow = False
    End If

    If IsWindowVisible(hWndAccessApp) = 1 Then
    fSetAccessWindow = True
    End If
    End If


    End Function

    I then have two buttons on a form coded as below:-

    Option Compare Database
    Private Sub cmd_Hide_dbw_Click()
    Call fSetAccessWindow("Minimize", False, False)
    DoCmd.OpenForm "frm_Test", acNormal
    End Sub

    Private Sub cmd_Show_dbw_Click()
    Call fSetAccessWindow("Show", False, False)
    DoCmd.OpenForm "frm_Test", acNormal
    End Sub

    I have attached a Test Database which demonstrates the problem I am experiencing.

    Do the following sequence...............

    Open the Test Database. DO NOT ENABLE CONTENT
    The Access 'Ribbon'Test_Database.accdb is active and usable
    Open frm_Test in Design View in order to inspect, all should be as shown above.
    Now click the Enable Content warning
    Switch frm_Test to Form View

    Click button Hide dbw. Closes the Access Window
    Click button Show dbw. Opens the Access Window...HOWEVER....

    Attachment 20252The Access Ribbon is locked and usable !!!

    I cannot find a way to re-activate the Ribbon

    Any help greatly appreciated.

    jcc285

  2. #2
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104
    If, as you state at the very top of the subject, you only wish to hide or show the database windows, this can be achieved using these one or two lines of code behind your buttons:

    CmdButton to SHOW database window OnClick

    DoCmd.SelectObject acTable, "TblName", True
    CmdButton to HIDE database window OnClick

    DoCmd.SelectObject acTable, "TblName", True
    DoCmd.RunCommand acCmdWindowHide

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The function you are using is used to minimize, maximize, hide, etc. Window's windows. In order for this technique to work, a couple of things need to happen. First, all of your forms have to be Pop Up forms. Second, the Access file needs to be in a trusted location for the code to work (enable content). Also, the ptrsafe thing is in case the version of Access being used is 64 bit. The default for Office is 32 bit.

    What are you trying to do? Are you trying to hide the Navigation Pane? You can do this via the Options. If there are objects within the Nav Pane that you want to keep hidden, even if someone overrides the options, you can run code to hide the objects. With this, the only way to unhide the objects is via VBA.

    Application.SetHiddenAttribute acTable, "NameOfTAble", True

    Edit: Doh, this is a necrothread!

  4. #4
    Edward_ is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    38
    DubCap01 or anyone

    I'm migrating an access 2003 db/application to 2007.

    I'm testing the above method to hide the DB window objects. But strangely, the db window tools and objects are all hidden, with only the Access 2003 Windows border, Only when I launch my startup form manually from within Access. When I launch the app from the MyApp.MDB, the Ribbon, Quick Access Toolbar, and Office Button are still displayed.

    Startup form code:
    Code:
    Forms![Splash Screen].TimerInterval = 2000DoCmd.SelectObject acTable, "tblOrders" , True  '*** Hides Database Window (or Did hide it) ****
    DoCmd.ShowToolBar "Ribbon", acToolbarNo       '***
    DoCmd.RunCommand acCmdWindowHide           '***
    My first objective is to hide everything except the minimum Microsoft Access border, having only the minimize, maximize, and X buttons upper right.

    Any advice appreciated.

  5. #5
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104
    Edward_,
    What happens after the startup form is finished with? Does it then open up a menu page or something (switchboard)?
    Try this in the On Current event procedure
    Code:
            If Not CommandBars.GetPressedMso("MinimizeRibbon") Then
                    CommandBars.ExecuteMso "MinimizeRibbon" '<this will toggle state, hence the check first.
            End If
    You can set the DB window to be hidden under database options (File - Options - Current Database - Navigation (untick Navigation Pane))

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hiding controls off form window view
    By mrod in forum Forms
    Replies: 1
    Last Post: 04-02-2015, 12:34 PM
  2. Replies: 2
    Last Post: 04-07-2014, 10:01 AM
  3. Hiding ribbon window
    By data808 in forum Access
    Replies: 18
    Last Post: 03-22-2014, 04:42 PM
  4. Hiding/Showing a Group of Controls
    By EddieN1 in forum Reports
    Replies: 6
    Last Post: 01-25-2014, 04:16 PM
  5. Outlook 2013 + Access 2013 + HTML
    By Yann63 in forum Programming
    Replies: 2
    Last Post: 11-26-2013, 02:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums