2011-03-09 22 views
0

fAccessWindow(“隐藏”,假,假)隐藏实际的访问窗函数给出编译错误编号7960fAccessWindow(“隐藏”,假,假)给出编译错误

我没有空间已经试过“fAccessWindow(”隐藏“,假,假)”但没有区别。我也有一个模块,下面的代码也可以找到here。我正在使用最低级别的宏安全性的Access 2010。另外我的操作系统是x64。

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 
+0

首先,你不表明你说的是导致编译错误代码(你”重新显示被调用的代码,但不是调用它的代码正在生成错误);其次,你没有显示你得到的实际错误信息。请提供这些详细信息以便人们能够帮助您。 – 2011-03-09 22:40:26

+0

“编译此函数时出现错误”,则宏名称,操作名称“RunCode”,参数“fAccessWindow(”Hide“,False,False)”错误编号“7960” – 2011-03-09 22:43:33

回答

2

您需要参考this article from MS on 64-bit VBA和使用不仅仅是PTRSAFE,也是新龙龙的数据类型,你需要使用条件编译:

#if Win64 then 
     Private Declare PtrSafe Function IsWindowVisible Lib "user32" (ByVal hwnd As LongLong) As LongLong 
    #else 
     Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long 
    #end if 

我不是编程64位访问,所以没有与此工作。我不清楚Win64和VBA7编译常量之间的相互作用是什么,引用的文章不完全清楚。这不是我清楚,如果你应该这样做:

#If Win64 And VBA7 Then 
     ... 
    #Else 
     ... 
    #End If 

,或者如果它应该是:

#If Win64 Then 
     #If VBA7 Then 
     ... 
     #Else 
     ... 
     #End If 
    #Else 
     #If VBA7 Then 
     ... 
     #Else 
     ... 
     #End If 
    #End If 
0

我添加PTRSAFE选项下面的功能,并开始在x64的工作,但现在它是给在x86机器上同样的错误。

Private Declare PtrSafe Function IsWindowVisible Lib "user32"_ 
    (ByVal hwnd As Long) As Long 

Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ 
    ByVal nCmdShow As Long) As Long