ACC1x: Validating Data with Values from Another TableID: Q96973
|
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.
You can use a validation expression to compare the value entered by the
user with a value in one or more other tables. You can create a validation
rule to accept only values that exist in a second table or to reject values
that exist in a second table.
Table: Table1
---------------------------------------------------------
Field Name: Field Name
Data Type: Text
Validation Rule: DCount("[Field]","Table2","[Field]='" &_
[Field in Table1] & "'") > 0
Table: Table1
---------------------------------------------------------
Field Name: Field Name
Data Type: Text
Validation Rule: DCount("[Field]","Table2","[Field]='" &_
[Field in Table1] & "'") = 0
Table: Table1
----------------------------------------------------------
Field Name: Field Name
Data Type: Text
Validation Rule: DLookup("[Field]","Table2","[Field]='" &_
[Field in Table1] & "'")Is Not Null
Table: Table1
----------------------------------------------------------
Field Name: Field Name
Data Type: Text
Validation Rule: DLookup("[Field]","Table2","[Field]='" &_
[Field in Table1] & "'")Is Null
Microsoft Access "User's Guide," version 1.0, pages 45 and 652
Keywords : kbusage GnlValid
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: March 20, 1999