Tell Us: How do you validate data?
We build a lot of sample applications on the team to test stuff. Jeff Conrad is putting together a database to track the NFL season and needed a way to make it impossible to create multiple records of the same teams playing each other in the same week and same year.
He created a compound index on the table.
You supply a name for the index in the Index Name column. You then list all the fields you want to use for this compound index in the Field Name column. It’s very important that for the additional fields, you don’t put the same (or anything) index name in the left column. Otherwise, Access thinks it’s a completely different index. You can also set a Sort Order, but I don’t see much value in doing that.
In the bottom left corner, you’ll notice that the Unique property is set to Yes. By default this is No so you need to remember to set that to Yes in order to only accept a unique compound index of those fields.
Of course you could also enforce this through table level validation or VBA/Macros on the form level. How do you solve this kind of problem in your databases? Tell us!