ACC2002: Data Access Page Does Not Display Default Values in New Records (282362)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q282362
Novice: Requires knowledge of the user interface on single-user computers.

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

SYMPTOMS

When you add a new record in a data access page that contains an object with a ControlSource property that is a field with a default value, the default value does not appear in the new record as expected. Additionally, the DefaultValue property is not populated as expected.

CAUSE

The DefaultValue property on the page is an ElementExtension. When you create a data access page in Design view in a Microsoft Access database (.mdb), the default value is copied from the table to the data access page. The field's DefaultValue property that you set in the Design view of the table includes a leading equal sign, similar to the following:

= "USA"

The data access page object extended DefaultValue property adds an equal sign to the table's default value without acknowledging the equal sign that is already there, similar to the following:

== "USA"

This behavior prevents the DefaultValue property from functioning correctly.

This behavior is not the same as when you use the Page Wizard or Autopage: Columnar to create your new page. Under either of those circumstances, the wizard does not create the ElementExtension and copy the default value. Therefore, the DefaultValue property is not populated in the Property Sheet, and default values do not appear in newly created records.

In an Access project (.adp), the default value is not copied to the Data Source Control's ElementExtension. Instead, it is retrieved from the respective Extended property on the Microsoft SQL Server computer. Default values appear as expected when you add a new record in your new page; however, the DefaultValue property is not populated. If you change the DefaultValue property on the page in an .adp file, the ElementExtension is created and overrides the SQL Server extended property.

RESOLUTION

To work around this issue, in an Access database (.mdb), when you add a default value to a field in the table's Design view, do not use a leading equal sign. In the table, the DefaultValue property is parsed correctly, with or without the leading equal sign. The default property ="MyDefault" is equivalent to "MyDefault".

In an Access project (.adp), the default value appears correctly when you create a new record in your page. However, the DefaultValue property appears blank in Design view. If you manually populate the DefaultValue property, the value that is entered overrides the default value stored in SQL Server.

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 Problem

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. Open the Categories table in Design view.
  3. Under Field Name, click Description.
  4. Under Field Properties in the Default Value box, type =MyDefault.

    Note that Access adds quotation marks automatically.
  5. Close and save the table.
  6. In the Database window, under Objects, click Pages, and then click New.
  7. In the New Data Access Page dialog box, click Design View, and then click OK. Click OK again to clear the warning about compatibility with Access 2000.
  8. From the field list, drag Description to the center of the data access page.
  9. On the View menu, click Properties, and then click the Data tab.

    Notice that the Default Property box contains =="MyDefault".
  10. On the View menu, click Page View.
  11. On the Navigation bar on the data access page, click the New button to add a new record. Note that the Description text box in the new record is blank, and no default is displayed.

Modification Type:MinorLast Reviewed:9/27/2006
Keywords:kbbug kbnofix KB282362