ACC: Microsoft Access Is Visible When Started Through Automation

Last reviewed: August 29, 1997
Article ID: Q167659
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

When you create an instance of Microsoft Access using Automation, the Microsoft Access application window is visible automatically.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

RESOLUTION

Use the CreateObject function to start a new instance of Microsoft Access, and then use the Windows application programming interface (API) procedure, ShowWindow, to hide the instance.

  1. Start Microsoft Access and open the sample database Northwind.mdb.

  2. Create a module and type the following lines in the Declarations section:

          Option Explicit
    

          Private Declare Function ShowWindow Lib "User32" _
          (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
    

  3. Type the following procedure:

          Sub StartAccessHidden()
          Dim sw As Long
          Dim appAccess As Object
          On Error Resume Next
    
          ' Start an instance of Microsoft Access.
          Set appAccess = CreateObject("Access.Application")
    
          ' Hide the instance of Microsoft Access.
          sw = ShowWindow(appAccess.hWndAccessApp, False)
          If Err.Number = 0 Then
             MsgBox "The instance of Microsoft Access was started " & _
                    "and hidden successfully.  Click OK to view the " & _
                    "instance."
    
             ' Unhide the instance of Microsoft Access.
             appAccess.Visible = True
             appAccess.UserControl = True
          Else
             Err.Clear
             MsgBox "The instance of Microsoft Access was not " & _
                    "started successfully."
          End If
          End Sub
    
    

  4. To test this procedure, type the following line in the Debug window, and then press ENTER.

          StartAccessHidden
    

    Note that an instance of Microsoft Access is started and is immediately hidden. After you click OK in the message box, the instance of Microsoft Access becomes visible. To close the second instance of Microsoft Access, click Exit on the Microsoft Access File menu.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Access 7.0 and 97. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Most applications are not visible by default when you activate them with Automation. Although Microsoft Access exposes a Visible property, it does not hide or show the instance of Microsoft Access. Instead, the Visible property controls whether or not Microsoft Access is minimized.

Steps to Reproduce Problem

  1. Open the sample database Northwind.mdb.

  2. Create a module and type the following line in the Declarations section if it is not already there:

          Option Explicit
    

  3. Type the following procedure:

          Sub StartAccess()
          Dim appAccess As Object
    
             ' Start an instance of Microsoft Access.
             Set appAccess = CreateObject("Access.Application")
             appAccess.UserControl = True
          End Sub
    
    

  4. To test this procedure, type the following line in the Debug window, and then press ENTER.

          StartAccess
    

    Note that an instance of Microsoft Access starts and is fully visible. To close the instance of Microsoft Access, click Exit on the Microsoft Access File menu.

REFERENCES

For more information about using Microsoft Access as an Automation server, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q147816
   TITLE     : ACC: Using Microsoft Access as an Automation Server


Additional query words: OLE
Keywords : AutoGnrl kbinterop kbprg PgmApi
Technology : kbole
Version : 7.00 97
Platform : WINDOWS
Hardware : x86
Issue type : kbbug
Solution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.