Results 1 to 3 of 3
  1. #1
    erjohnson1 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    3

    Hide Access window and only show switchboard form

    I have a simple database that around 20 people are going to be entering data into. I'm trying to simplify this as much as possible to reduce the amount of problems they might run into. I have a switchboard form that gives the users everything they need to interact with (four forms and three reports) that I run on startup. I want to just show this switchboard form and nothing else to the users. I found a really nice piece of code that accomplishes this which can be seen here and copied below:


    Code:
    '************ Code Start **********
    ' This code was originally written by Dev Ashish.
    ' It is not to be altered or distributed,
    ' except as part of an application.
    ' You are free to use it in any application,
    ' provided the copyright notice is left unchanged.
    '
    ' Code Courtesy of
    ' Dev Ashish
    '
    Global Const SW_HIDE = 0
    Global Const SW_SHOWNORMAL = 1
    Global Const SW_SHOWMINIMIZED = 2
    Global Const SW_SHOWMAXIMIZED = 3
    
    
    
    
    Private Declare Function apiShowWindow Lib "user32" _
        Alias "ShowWindow" (ByVal hwnd As Long, _
              ByVal nCmdShow As Long) As Long
    
    
    Function fSetAccessWindow(nCmdShow As Long)
    'Usage Examples
    'Maximize window:
    '       ?fSetAccessWindow(SW_SHOWMAXIMIZED)
    'Minimize window:
    '       ?fSetAccessWindow(SW_SHOWMINIMIZED)
    'Hide window:
    '       ?fSetAccessWindow(SW_HIDE)
    'Normal window:
    '       ?fSetAccessWindow(SW_SHOWNORMAL)
    '
    Dim loX  As Long
    Dim loForm As Form
        On Error Resume Next
        Set loForm = Screen.ActiveForm
        If Err <> 0 Then 'no Activeform
          If nCmdShow = SW_HIDE Then
            MsgBox "Cannot hide Access unless " _
                        & "a form is on screen"
          Else
            loX = apiShowWindow(hWndAccessApp, nCmdShow)
            Err.Clear
          End If
        Else
            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
        End If
        fSetAccessWindow = (loX <> 0)
    End Function
    
    
    '************ Code End **********
    I have this pasted into a module, and on startup I call fSetAccessWindow(SW_HIDE). The only problem that I have run into is I'm not able to open any reports from my switchboard. Forms work perfectly, but reports don't open at all. Access ends up freezing up and I have to go into the task manager and end the program. I've tried numerous work arounds included using the fSetAccessWindow(SW_SHOWMAXIMIZED) function call when opening any report, but that doesn't work either as access gets really weird when closing the report. I also have all my reports set as popup and modal.




    Does anybody know how to modify this piece of code so I could have the same functionality with reports as I do with forms? Or does anybody know of another solution? This isn't really a game changer for my database as I have the database closing once the startup form (which is popup and module) closes meaning the users can already only interact with the switchboard form, but being able to hide the stuff would make it even cleaner.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    hide the db with:

    DoCmd.SelectObject acTable, , True
    DoCmd.RunCommand acCmdWindowHide

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,445

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

Similar Threads

  1. Replies: 5
    Last Post: 10-29-2017, 06:46 AM
  2. Replies: 3
    Last Post: 09-20-2014, 04:10 AM
  3. Hide the Access Background Window
    By SltPhx in forum Access
    Replies: 3
    Last Post: 01-31-2013, 01:49 PM
  4. Hide Access 2010 runtime window
    By cevatyildiz in forum Programming
    Replies: 4
    Last Post: 03-28-2011, 07:28 AM
  5. Hide database window in Access 2010
    By Kevin Johnston in forum Access
    Replies: 5
    Last Post: 09-23-2010, 09:44 AM

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