我正在将Access 2007用于我的Access 2003 MDB项目,并且在尝试显示查询结果时遇到了一些问题。这里没什么好看的:
DoCmd.OpenQuery "myQuery", acViewNormal
以简单的形式,效果很好。但是,我正在使用以下代码隐藏后台Access窗口:
Private Declare Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
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(1)来恢复完整的界面,但我想在这里只显示查询结果而不是Access的完整界面。可能吗?一些用户使用批处理文件运行数据库(不确定它是否会产生任何影响):
start msaccess /runtime "myFile.mdb"
另外,因为我的所有表单都是模态(它必须在没有界面的情况下工作或者窗口只是不显示),查询结果会在后台显示而无需任何设置焦点(用户必须关闭活动的应用程序窗口以执行此操作。)
答案 0 :(得分:1)
似乎除了使用查询作为记录源构建表单之外没有其他解决方案。