The information in this article applies to:
SUMMARY
The text below presents two examples that demonstrate setting the
ValidationRule property to use values in a different table. You must use
either the DCount() or DLookup() function to do this.
MORE INFORMATIONExample 1: Using the DCount() FunctionIn the following example, the user can enter into "Table1" only those values that exist in the "Field" field of "Table2."NOTE: In the following examples, an underscore (_) is used as a line- continuation character. Remove the underscores when re-creating these examples.
In the following example, the user can enter into "Table1" only those values that do not exist in the "Field" field of "Table2."
Example 2: Using the DLookup() FunctionIn the following example, the user can enter into "Table1" only those values that exist in the "Field" field of "Table2."
In the following example, the user can enter into "Table1" only those values that do not exist in the "Field" field of "Table2."
Replace "Field" with the appropriate field name in your database (be sure to preserve the quotation marks and square brackets). Replace "Table2" with the name of the validation table in your database and replace "Table1" with the name of the table in which you are entering data. DCount() searches through the specified field in the validation table and counts all records where the field name is equal to the value entered in the table. If the function returns a value greater than zero, the function found one or more matching records. REFERENCESMicrosoft Access "User's Guide," version 1.0, pages 45 and 652
Keywords : kbusage GnlValid |
Last Reviewed: March 20, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |