0

I have a access database with some forms and vba code behind the forms.

On Form_Open (on every form) I have this piece of code.

Dim hWindow As Long
Dim nResult As Long
Dim nCmdShow As Long

    hWindow = Application.hWndAccessApp
    nCmdShow = SW_HIDE
    nResult = ShowWindow(ByVal hWindow, ByVal nCmdShow)
    Call ShowWindow(Me.hWnd, SW_NORMAL)

This hides Access and shows only the opened form.

My problem is that Access is starting, but the form will not open.

I have to kill the Access task in task manager.

Is there any way to solve the problem?

EDIT: Every form is a PopUp

1 Answer 1

2

As I understand, you need to hide main form and leave popup form open. I normally use window opacity settings instead of hiding:

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Private Const LWA_ALPHA     As Long = &H2&
Private Const LWA_COLORKEY  As Long = &H1&
Private Const GWL_EXSTYLE   As Long = -20
Private Const WS_EX_LAYERED As Long = &H80000

Public Function SetWndOpacity(hwnd As Long, opacity As Byte, clr As Long)
    DoCmd.Maximize
    SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
    SetLayeredWindowAttributes hwnd, 0&, opacity, LWA_ALPHA
End Function

Then call:

SetWndOpacity Access.hWndAccessApp(), 0, 0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.