ACC: How to Display Immediate Window Without Module WindowID: Q89594
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
Microsoft Access does not display the Immediate window unless the Module
window is visible. This can be a problem if the user wants to print to the
Immediate window while in Datasheet view of a form. By calling two Windows
application programming interface (API) functions from Access Basic, the
Immediate window can be displayed at any time, even without the Module
window visible.
NOTE: In Microsoft Access for Windows 95 version 7.0 you no longer have to
have a module open to display the Debug window. The Debug window can be
brought up anytime in an active database by pressing CTRL+G.
To display the Immediate window at any time, you need to call the
FindWindow() API function to get the handle to the Immediate window,
and then call the ShowWindow() API function to make the actual window
visible. You can attach the Access Basic function that includes these
API functions to a command button or a RunCode action in the Autokeys
macro, or you can add it to your toolbar.
To display the Immediate window, follow these steps:
Declare Function ShowWindow% Lib "user" (ByVal hWnd%, ByVal nCmd%)
Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any, _
ByVal lpWindowName As Any)
Function ShowImmediateWindow ()
Dim IhWnd% ' Handle to the Immediate Window.
Dim ApiResults% ' Returns the previous state of IW.
Const MyNull = 0&
Const SW_SHOW = 5 ' Internal constant to show window.
Const ClassName = "OImmediate" ' Internal ClassName of IW.
IhWnd% = FindWindow(ClassName, MyNull)
If IhWnd% = 0 Then
MsgBox ("You need to open the IW once for this to work.")
End If
ApiResults% = ShowWindow(IhWnd%, SW_SHOW)
End Function
Keywords : kbprg
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 9, 1999