I have a list of keys (actual physical keys for locks). Each key has a unique identifier. I issue those keys to people. When issuing keys I have a dropdown on a ref column with a Valid_if constraint which only lists for me keys that have not already been issued; I do this by list subtraction (list of all keys minus list of used keys=list of unused keys). This all works peachy fine until I want to edit the record. Lets say a person returns their key and I want to enter a date to the โDate Returnedโ column I find Iโm getting an invalid entry warning on the key ref column. The key is now already issued and so thereโs nothing available in the dropdown and the entry fails on Valid_If. Iโm not creating a new record, just updating an old one. Any suggestions?
Oh hi Mark (sorry couldnโt resist), you could use the CONTEXT() function inside an if() like this:
IF(
Context(โViewโ)=โThe view where you edit your recordsโ,
TRUE,
Your actual Valid_if formula)
What this should accomplish is to only allow you to select any keys when editing a record, you could use list addition to make it only allow you to choose between the unused keys + the key in the record youโre editing, but for the purpose of changing the โDate Returnedโ field this should work.
Edit: forgot the
Thank you for the help. Iโll play with that tonight when Iโm back home. In the meantime I gave the solution a quick whirl and came up with the error as attached.
My bad, based on the columns on your screenshot iโll correct the expression as follows:
IF(
Context(โViewโ)=โIssue_Formโ,
IKey[KeyID],
IKey[KeyID]-Issue[KeyID])
List subtraction is the right way to go, you just need to not subtract the current rowโs value:
(
IKey[KeyID]
- SELECT(
Issue[KeyID],
([_ROWNUMBER] <> [_THISROW].[_ROWNUMBER])
)
)
Beautiful. 100%.
User | Count |
---|---|
38 | |
35 | |
27 | |
23 | |
18 |