ACC: Null Value Does Not Pass Validation Rule

Last reviewed: May 28, 1997
Article ID: Q117542
The information in this article applies to:
  • Microsoft Access versions 2.0, 7.0, 97

SYMPTOMS

Novice: Requires knowledge of the user interface on single-user computers.

You cannot leave a field blank, or Null, in a table's Datasheet view if the field has a validation rule.

CAUSE

This behavior only occurs when adding a new record with two fields, one of which has a data type of AutoNumber (or Counter in version 2.0).

This behavior differs from that of Microsoft Access version 1.x. In Microsoft Access 1.x, a Null value is accepted for a field even if "Or Is Null" is not part of the validation rule.

RESOLUTION

Include "Or Is Null" as part of the validation rule for the field. For example, a validation rule for a text field could be:

   "A" Or "B" Or Is Null

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create the following new table and save it as Table1:

          Table: Table1
          ---------------------------------------------------
          Field Name: ID
    
             Data Type: AutoNumber (or Counter in version 2.0)
          Field Name: Code
             Data Type: Text
             Validation Rule: "A" Or "B" Or Is Null
    
    

  2. View the table in Datasheet view.

  3. Select the Code field. Type "A" (without the quotation marks) and press ENTER. Note that you can move to the next record.

  4. In the next record, press TAB to move to the third record. Note that you cannot move to the next record because the Code field cannot initially be Null. This is because there is only one user input field defined in this table, and the record cannot be saved until it has received some input.

  5. Select the Code field in the second record. Type "A" (without the quotation marks) and press ENTER. Delete the "A" from the field, and press TAB. Note that you can move to the next record now because the record was initially saved with data.

REFERENCES

For more information about the ValidationRule property, search for "ValidationRule property," and then "Create a validation rule for a control" using the Microsoft Access 97 Help Index.

For more information about using Null values in a validation rule, search for "ValidationRule property," and then "ValidationRule, ValidationText Properties" using the Microsoft Access 97 Help Index.


Keywords : kbusage TblFldp
Version : 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.