ACC2002: Drop-Down List on Data Access Page Does Not Stay in Sync with Recordset (274387)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q274387
Advanced: Requires expert coding, interoperability, and multiuser skills.

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

SYMPTOMS

When you delete a record on a data access page, a combo box that is used to find records on the page is not refreshed to reflect the deletion.

CAUSE

A combo box on data access pages is not automatically refreshed after a deletion in the underlying recordset.

RESOLUTION

In order to refresh the combo box, set the ServerFilter property to an empty string, as follows:
  1. Open the Northwind sample database.
  2. Open the Customers table, add a record as follows, and then close the table:
       CustomerID:   AAAAA
       CompanyName:  TestCompany
    					
  3. In the Database window, click the Customers table, and then on the Insert menu, click Page.
  4. In the New Data Access Page dialog box, click AutoPage: Columnar, and then click OK.
  5. After the page has been created, click Design View on the View menu.
  6. Click the arrow next to Customers on the Header bar, and then click Group Level Properties.
  7. Change the CaptionSection property to True.
  8. In the toolbox, click Control Wizards so that the tool appears with a box around it, and then use the wizard to add a combo box to the Caption: Customers section of the page.
  9. In the wizard, add the CustomerID and CompanyName fields from the Customers table to the combo box, and then accept all other defaults.
  10. Right-click the combo box, click Element Properties, click the All tab, and then change the ID property of the combo box to cboFindCustomer.
  11. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  12. In the Client Objects & Events drop-down list, click cboFindCustomer.
  13. In the Event drop-down list, click onchange.
  14. Type the following code for the onchange event of the combo box:
    dim rs
    set rs = MSODSC.DefaultRecordset
    rs.Find "CustomerID = '" & cboFindCustomer.value & "'", 0, 1, 1
    					
  15. In the Client Objects & Events drop-down list, click MSODSC.
  16. In the Event drop-down list, click afterdelete.IMPORTANT: When you create VBScript blocks for MSODSC events, you must add a parameter to the event name as follows:

    <SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>

    The <I>oEventInfo</I> parameter returns specific information about the event to the script. You must add this parameter, whether or not it will be used, because the script will not work without it.

  17. Type the following code for the afterdelete event:
    MSODSC.RecordsetDefs(0).ServerFilter = ""
    					
  18. Save, and then close the page.
  19. Open the page in Microsoft Internet Explorer, and then click TestCompany in the drop-down list.
  20. On the record navigation toolbar, click Delete, and then click Yes to the prompt confirming the deletion.
Note that after the record has been deleted, TestCompany no longer appears in the drop-down list.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Complete steps 1 through 14 in the "Resolution" section of this article.
  2. Open the data access page in Internet Explorer.
  3. In the caption section of the page, click TestCompany in the combo box.
  4. On the record navigation toolbar, click Delete to delete the TestCompany record.
  5. Open the combo box again. Note that TestCompany still appears.

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