Code to restore MS-Access window

Discussion in 'Access VBA Modules' started by JimP, Apr 20, 2007.

  1. JimP

    JimP Guest

    The code below works well to suppress and restore the MS-Access window, and
    only display a form when the window is suppressed. However, upon restoring
    the window I can't seem to find a way to make any Menubar or Toolbar
    visible. e.g.

    DoCmd.ShowToolBar "Menu Bar", acToolbarYes

    ...has no affect. Any ideas?

    '************ 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 **********
     
    JimP, Apr 20, 2007
    #1
    1. Advertisements

  2. JimP

    jhowkins

    Joined:
    Aug 8, 2012
    Messages:
    1
    Likes Received:
    0
    Code to Restore Access after hiding it using apiShowWindow

    Here is a simple fix to restore MS Access when you call the function for anything other than 0 (SW_HIDE)...

    Insert the line in red below;

    Code:
    ...
    fSetAccessWindow = (loX <> 0)
    [B][COLOR="Red"]Application.SetOption "Show Status Bar", True[/COLOR][/B]
    End Function
    
     
    jhowkins, Aug 8, 2012
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. zbook

    Access 2000 Hide Access Window

    zbook, Sep 15, 2004, in forum: Access VBA Modules
    Replies:
    2
    Views:
    126
  2. Greg-the-Greg
    Replies:
    1
    Views:
    161
    Douglas J. Steele
    Oct 16, 2004
  3. Robert_L_Ross

    Use code to delete and restore relationships

    Robert_L_Ross, Aug 12, 2005, in forum: Access VBA Modules
    Replies:
    3
    Views:
    76
    Brian
    Aug 13, 2005
  4. BlockNinja
    Replies:
    3
    Views:
    211
    BlockNinja
    Jan 2, 2006
  5. WhatTha
    Replies:
    0
    Views:
    276
    WhatTha
    Jan 24, 2006
  6. H2OBOWL
    Replies:
    6
    Views:
    122
    H2OBOWL
    Jul 12, 2006
  7. mb1946
    Replies:
    3
    Views:
    73
    Lincoln
    Apr 22, 2008
  8. Bob
    Replies:
    3
    Views:
    242
    Armen Stein
    Dec 6, 2009
Loading...