ACC97: How to Use the RefreshDatabaseWindow Method

ID: Q160950

The information in this article applies to:

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

When you create, delete, or rename an object through code while the object is visible in the Database window, the Database window does not reflect the changed object until the focus moves to a different object type and then back again. For example, if you create a new table, and the Table tab is selected in the Database window, you may not see the new table until you click another tab in the Database window, and then click the Table tab again.

This article shows you how to use the RefreshDatabaseWindow method of the Application object to refresh the Database window after you change an object.

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 the "Building Applications with Microsoft Access 97" manual.

MORE INFORMATION

You can use the RefreshDatabaseWindow method to immediately reflect changes to objects in the Database window, as the following example shows:

1. Open the sample database Northwind.mdb.

2. Select the Shippers table in the Database window.

3. On the Edit menu, click Copy.

4. On the Edit menu, click Paste. In the Paste Table As dialog box, type

   Shippers2 in the Table Name box, and then click OK.

5. Create a module and type the following procedure:

      Function TestRefresh()
         Dim db As Database
         Set db = CurrentDb()
         db.TableDefs.Delete "Shippers2"
         Application.RefreshDatabaseWindow
      End Function

6. Press F11 to bring the Database window to the foreground and click the
   Tables tab.

7. Press CTRL+G to open the Debug window. Position the Database window
   and the Debug window so both are visible. Type the following line in
   the Debug window, and then press ENTER.

      ?TestRefresh()

   Note that the Shippers2 table is removed from the Database window.

REFERENCES

For more information about the RefreshDatabaseWindow method, search the Help Index for "RefreshDatabaseWindow method."

Additional query words:

Keywords          : kbprg kbusage
Version           : 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto

Last Reviewed: November 20, 1998