Checkbox Validation Using SQL Code
Posted on 2011-10-17
I am trying to run some VB validation code when a Checkbox (PrimaryAcct) is changed. The Checkbox appears as part of a Repeater and is bound to a field (CAddr_PrimaryAcct) on a SQL table. For the group of records displayed by the Repeater (based on the Repeater record source being filtered), I need to ensure that one and only one record has the CAddr_PrimaryAcct field checked.
For example: The Repeater is displaying 3 records and one of them has the PrimaryAcct Checkbox checked. If the user attempts to add a new record and checks the PrimaryAccount Checkbox, I want to produce an error message saying that a PrimaryAcct has already been selected.
I know that I can use the OnCheckedChanged method of CheckBox to call the subroutine to do the validation, but how do I cancel the change to the Checkbox if I find that there is already a record with the field checked?