Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access Form_Open VBA代码不工作_Ms Access_Vba - Fatal编程技术网

Ms access Form_Open VBA代码不工作

Ms access Form_Open VBA代码不工作,ms-access,vba,Ms Access,Vba,我有一个access数据库,其中包含一些表单和表单后面的vba代码 在表单_Open(在每个表单上)我都有这段代码 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 Sh

我有一个access数据库,其中包含一些表单和表单后面的vba代码

表单_Open
(在每个表单上)我都有这段代码

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)
这将隐藏访问权限并仅显示打开的窗体

我的问题是访问正在启动,但表单不会打开

我必须在任务管理器中终止访问任务

有什么办法解决这个问题吗


编辑:每个表单都是一个弹出窗口

据我所知,您需要隐藏主表单并保持弹出窗口表单打开。我通常使用窗口不透明度设置,而不是隐藏:

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
然后打电话:

SetWndOpacity Access.hWndAccessApp(), 0, 0

据我所知,您需要隐藏主窗体并保持弹出窗体打开。我通常使用窗口不透明度设置,而不是隐藏:

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
然后打电话:

SetWndOpacity Access.hWndAccessApp(), 0, 0