I'm trying to create a validation rule in Access 2010 to set the value of a true/false field to True...
More details, I have a table with several yes/no fields and one true/false field and I want the true/false field to change to true only if all the yes/no fields are yes.
I'm trying to make it that it is set automatically after updating the fields and without the user changing it...
A Validation Rule can not alter a field's value. It can only indicate whether or not that value should be considered valid.
If you want a field which automatically updates itself to indicate whether other fields are all True, consider a calculated field or a data macro. Since you're using Access 2010, both those options are supported.
However, a simpler approach would be to decide you don't need that summary field to exist in your table design. You could use a query to derive it whenever you need to see it.
For example, with two Yes/No fields Fld1 and Fld2, a simple field expression will tell you whether both are True ...
SELECT Fld1, Fld2, (Fld1=True AND Fld2=True) AS all_are_true
That would present True as -1 and False as 0. If you want the query to show those values as True or False, you can use a Format
expression ...
SELECT Fld1, Fld2, Format((Fld1=True AND Fld2=True), 'True/False') AS all_are_true
That computation is a trivial workload for the db engine. And computing the field expression each time you run the query ensures all_are_true reflects the latest changes to the other fields.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments