Reputation: 3519
I'm using Access 2007 for my Access 2003 MDB project and I'm facing some problems while trying to show up the results of a query. Nothing fancy here:
DoCmd.OpenQuery "myQuery", acViewNormal
In a simple form, it works great. However, I'm hiding the background Access window with the following code:
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
I could obviously call for fSetAccessWindow(1) to bring back the full interface but I would like here to just show the query result and not the full interface of Access. Is it possible? Some users run the database with a batch file (not sure if it might have any impact):
start msaccess /runtime "myFile.mdb"
Also, because all my forms are modals (it must be to work without the interface or the windows just don't show), the query results are displayed in the background without any way to set focus on it (the user must close the active application window to do so).
Upvotes: 0
Views: 1062
Reputation: 3519
It seems like there is no other solution than building a form with uses the query as its record source.
Upvotes: 1