ACC2000: ValidationRule Property Parses Function Names Without Parentheses as Strings (209603)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q209603
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 type an expression in the ValidationRule property of a text box, and the expression contains a function name that has no parentheses or parameters, Microsoft Access evaluates the expression as a string instead of a function.

RESOLUTION

Put parentheses or parameters after all function names so that they can be correctly evaluated as functions instead of text strings. For example, use

=Date()

instead of:

=Date

MORE INFORMATION

Steps to Reproduce 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. Start Microsoft Access and open the sample database Northwind.mdb.
  2. In the Database window, under Objects, click Form, click New, and then click OK to create a new form not based on any table or query.
  3. If the Toolbox is not visible, on the View menu, click Toolbox.
  4. In the Toolbox, click the Text Box button, and then click in the center of the form's Detail section.
  5. If the property sheet is not visible, on the View menu, click Properties.
  6. On the form's property sheet, click the Data tab.
  7. Click the Validation Rule box, type >=Date, and then press ENTER.

    Notice that Microsoft Access automatically changes the expression that you entered from >=Date to >="Date".
  8. On the View menu, click Form.
  9. Type the current date in the text box.

    When you type a date such as 9 Jun 20 in the text box and press ENTER, you see the following error message:
    The value you entered doesn't meet the validation rule defined for the field or control.
    However, notice that the text box does accept the word "date," which is the word produced by Microsoft Access in the Validation Rule property of the text box.

REFERENCES

For more information about the ValidationRule property, click Microsoft Access Help on the Help menu, type validationrule, validationtext properties in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Modification Type:MinorLast Reviewed:7/15/2004
Keywords:kbprb kbusage KB209603