Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    106

    Unanswered: Make Access Invisible

    Can anyone help me?
    I would like to make access invisible and display a form. I've been told that you can't make Access invisible but i have done that!

    However, i can't display a form while access is invisible. It has to be possible as you can do this in Excel and i'm sure Access can do anything that Excel can!!

    Here's the function i have so far:

    Private Declare 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 Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
    ByVal nCmdShow As Long) As Long

    Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
    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
    fAccessWindow = False
    End If
    If IsWindowVisible(hWndAccessApp) = 1 Then
    fAccessWindow = True
    End If
    End If
    End Function

  2. #2
    Join Date
    Sep 2003
    Location
    Nevada
    Posts
    8

    Try this instead

    I tried the code you are using and had the same problems you are having.

    I found the following code does the job perfectly:

    ' This part goes in your FORM Open statement
    ' NOTE: I have found that the DoCmd.Run statement needs to
    ' be commented out with some forms. Do not know why!!
    Private Sub Form_Open(Cancel As Integer)
    fSetAccessWindow (SW_SHOWMINIMIZED)
    DoCmd.RunCommand acCmdSizeToFitForm
    End Sub


    'ALL of this will go into you VAB modal
    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)
    '************ 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

    '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

  3. #3
    Join Date
    Aug 2003
    Posts
    106

    Thanks

    Thanks for this, i will give it a try!

    I have also found that some of the reason my code didn't work, was related to the 'Pop Up' property of the form.

    If the 'Pop Up' is set to True, less problems seem to occur,

    Thanks again,

    sugarflux

Posting Permissions

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