Checkbox Validation Using SQL Code

Posted on 2011-10-17
Last Modified: 2012-05-12
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?
Question by:Donna Kainer
    LVL 18

    Expert Comment

    Why not run a SQL query when the page gets loaded to see if the PrimaryAcct has already been populated, if it has, then disable the CheckBox, if not, then the CheckBox is enabled.

    Accepted Solution

    As usual, when I get the key words correct and with enough surfing of the web, I am able to eventually find the solution myself.

    This time the answer was found while reading between the lines in

    Author Closing Comment

    by:Donna Kainer
    I had to read between the lines but the solution referenced solved my problem.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now