ACC2002: RepaintObject Command Removes Objects from an Unsaved Data Access Page (295176)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q295176
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you use the RepaintObject method or action, all objects that you added to a data access page since you last save the page are lost.

CAUSE

The RepaintObject command reloads the page from the persisted copy of the page, which does not include unsaved objects.

RESOLUTION

Save the data access page before you use the RepaintObject method or action.

MORE INFORMATION

Steps to Reproduce the Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Open the sample database, Northwind.mdb.
  2. On the View menu, point to Database Objects, and then click Pages.
  3. Click New.
  4. In the New Data Access Page dialog box, click Design View, click the Customers table in the Choose the table or query where the object's data comes from box, and then click OK.
  5. In the field list, right-click the CompanyName field, and then click Add To Page on the shortcut menu.
  6. Save the page as DAPtest.htm.
  7. In the field list, right-click the ContactName field, and then click Add To Page on the shortcut menu.
  8. Press CTRL+G to open the Immediate window.
  9. Type the following line in the Immediate Window, and then press ENTER:
    DoCmd.RepaintObject
    					
  10. Note that the CompanyName text box is displayed on the page, but that the ContactName text box is removed.

Modification Type:MinorLast Reviewed:9/27/2006
Keywords:kbDAP kbnofix kbprb KB295176