我想永久隐藏访问窗口。我有一个最初隐藏窗口的自动exe宏,但如果用户点击任务栏上的数据库图标,如果出现在我的表单后面,那就太烦人了。我想知道是否有办法让它保持下来而不必复制过每一个隐藏窗口宏
答案 0 :(得分:1)
以下内容适用于旧版本的访问权限(来源:http://www.vbaexpress.com/kb/getarticle.php?kb_id=74):
Option Compare Database
Option Explicit
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)
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
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
fSetAccessWindow = (loX <> 0)
End Function
只需致电fSetAccessWindow(0)
隐藏,fSetAccessWindow(1)
即可显示。或者,您可以使用fSetAccessWindow(2)
和fSetAccessWindow(3)
来显示最小化/最大化。该应用程序也将隐藏在任务栏中,阻止用户单击它。
如果它不适用于Access 2010,您也可以尝试:http://www.tek-tips.com/faqs.cfm?fid=2562