Hide Access Application & Open Forms

karl009

Registered User.
Local time
Today, 01:29
Joined
Mar 2, 2010
Messages
55
Hi,

After coming across the below code and [FONT=&quot]having [/FONT]a play around I have come to a brick wall.

I have been able to get my splash screen up, then after that my Main Menu Form with the Access application hidden, but then when I click on any of my buttons to open other forms nothing.

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)
[B]'Usage Examples[/B]
[B]'Maximize window:[/B]
[B]'       ?fSetAccessWindow(SW_SHOWMAXIMIZED)[/B]
[B]'Minimize window:[/B]
[B]'       ?fSetAccessWindow(SW_SHOWMINIMIZED)[/B]
[B]'Hide window:[/B]
[B]'       ?fSetAccessWindow(SW_HIDE)[/B]
[B]'Normal window:[/B]
[B]'       ?fSetAccessWindow(SW_SHOWNORMAL)[/B]
[B]'[/B]
Dim loX  As Long
Dim loForm As Form
    On Error Resume Next
    Set loForm = Screen.ActiveForm
    If Err <> 0 Then [B]'no Activeform[/B]
      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

[B]'************ Code End ********[/B]
After searching the internet and trying a number of things am lost.

On the forms am trying to open I have tested the following code;

Code:
Private Sub Form_Load()
    Call fSetAccessWindow(SW_HIDE)
End Sub
Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorPoint

    Me.Visible = True
    fSetAccessWindow (SW_HIDE)
    
ExitPoint:
    Exit Sub
    
ErrorPoint:
    MsgBox "The following error has occurred:" _
    & vbNewLine & "Error Number: " & err.Number _
    & vbNewLine & "Error Description: " & err.Description _
    , vbExclamation, "Unexpected Error"
    Resume ExitPoint
    
End Sub
Thanks for any help on this...
 
My suggestion - abandon the attempts. It is way more complex to remove the Access Window and then manage how forms and reports need to be opened (and in a specific order) than it is worth.

I used to try to do that many years ago, but found that it really doesn't matter if the Access window is up. If you want an application that acts like a stand alone application, build one out of VB6 or VB.NET.
 

Users who are viewing this thread

Back
Top Bottom