home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / dbase / acessq_a.zip / Q89594.TXT < prev    next >
Text File  |  1992-11-09  |  3KB  |  69 lines

  1. How to Display Immediate Window Without Module Window  
  2.  
  3. Summary:
  4.  
  5. Access version 1.0 does not display the Immediate window unless the
  6. Module window is visible. This can be a problem if the user wants to
  7. print to the Immediate window while in browse mode of a form. By
  8. calling two Windows API functions from Access Basic, the Immediate
  9. window can be displayed at any time, even without the Module window
  10. visible.
  11.  
  12. More Information:
  13.  
  14. To display the Immediate window at any time, you will need to call the
  15. FindWindow API function to get the handle to the Immediate window, and
  16. then call the ShowWindow API function to make the actual window
  17. visible. You can attach the Access Basic function that includes these
  18. API functions to a command button, a SendKeys action in the Autokeys
  19. macro, or add it to your Toolbar.
  20.  
  21. To display the Immediate window, do the following:
  22.  
  23. 1. Create a new module, or open an existing module.
  24.  
  25. 2. Add the following declarations to the Global section of the module:
  26.    (You must include each declaration on a separate line.)
  27.  
  28.    Option Explicit
  29.    Declare Function ShowWindow% Lib "user" (ByVal hWnd%, ByVal nCmd%)
  30.    Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any,
  31.  
  32. 3. Add the following ShowImmediateWindow function:
  33.  
  34.    Function ShowImmediateWindow ()
  35.       Dim IhWnd%                'Handle to the Immediate Window
  36.       Dim ApiResults%           'Returns the previous state of IW
  37.       Const MyNull = 0&
  38.       Const SW_SHOW = 5         'Internal constant to show window
  39.       Const ClassName = "OImmediate"    'Internal ClassName of IW
  40.  
  41.       IhWnd% = FindWindow(ClassName, MyNull)
  42.  
  43.       'Note that the MsgBox function must be on one line.
  44.       If IhWnd% = 0 Then MsgBox _
  45.                   ("You need to open the IW once for this to work.")
  46.  
  47.       ApiResults% = ShowWindow(IhWnd%, SW_SHOW)
  48.    End Function
  49.  
  50. 4. Attach the code to a command button of a form.
  51.  
  52. 5. When you first start Access, the Immediate window is not displayed.
  53.    When you open a module and display the Immediate window then close
  54.    it, Access sets the window's Visible property to False. Calling
  55.    ShowWindow will reset the Visible property to True. If you call
  56.    this function without first displaying the Immediate window at
  57.    least once, you will receive the error message, because Access has
  58.    not created the Immediate window yet, and thus cannot return a
  59.    window handle.
  60.    
  61. 6. If you have registered the Immediate window with Windows by opening
  62.    it at least once, pressing the command button of the form while in
  63.    browse mode will display the Immediate window. Any Debug.Print
  64.    statements will now be visible.
  65.  
  66. Note: This is unsupported code, and there may be instances when this
  67. example will not work.
  68.  
  69.