Hello,
A valid_if is set to test for uniqueness of a field value, ie no other record in the table has the same value.
The test works correctly for new records.
Editing an existing record throws the valid_if error.
How can we apply Valid_if to NEW records, Only?
Solved! Go to Solution.
You probably want to apply Valid_If to existing records, too, in case the user changes the existing value.
NOT(
IN(
[MyColumn],
SELECT(
MyTable[MyColumn],
([KeyColumn] <> [_THISROW].[KeyColumn])
)
)
)
SELECT(MyTable[MyColumn], ...)
gathers MyColumn column values in the MyTable table from rows that match the given criteria.
([KeyColumn] <> [_THISROW].[KeyColumn])
matches only rows where the rowโs KeyColumn column value does not match the same columnโs value of the row in the form. In effect, this condition matches all rows that arenโt the row in the form, and so the SELECT() then returns a list of all MyColumn values from rows that arenโt this row. โWhat are the values in other rows?โ
IN([MyColumn], ...)
attempts to locate the formโs MyColumn value in the list gathered by SELECT(). โDoes this value occur in any other rows?โ
NOT(...)
inverts the answer given by IN(). โDoes this value not occur in other rows?โ
Not sure, but you could try this in the Valid_If:
IF(IN([Column], SELECT(TableName[Column], TRUE)), TRUE, <>)
You probably want to apply Valid_If to existing records, too, in case the user changes the existing value.
NOT(
IN(
[MyColumn],
SELECT(
MyTable[MyColumn],
([KeyColumn] <> [_THISROW].[KeyColumn])
)
)
)
SELECT(MyTable[MyColumn], ...)
gathers MyColumn column values in the MyTable table from rows that match the given criteria.
([KeyColumn] <> [_THISROW].[KeyColumn])
matches only rows where the rowโs KeyColumn column value does not match the same columnโs value of the row in the form. In effect, this condition matches all rows that arenโt the row in the form, and so the SELECT() then returns a list of all MyColumn values from rows that arenโt this row. โWhat are the values in other rows?โ
IN([MyColumn], ...)
attempts to locate the formโs MyColumn value in the list gathered by SELECT(). โDoes this value occur in any other rows?โ
NOT(...)
inverts the answer given by IN(). โDoes this value not occur in other rows?โ
Thanks Steve, Elegant and working!
Thanks as well Bellave for wading in to help.
User | Count |
---|---|
42 | |
34 | |
27 | |
23 | |
16 |