Full Version: Check Box On Continuous Form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
sugarcane
I have a continuous form with checkboxes that allow me to check only one at a time - this is fine. I'm just not sure how to enable only one to be checked at a time.

Thanks!
schroep
Your checkboxes need to be inside an option group.
sugarcane
Sorry - I gave you wrong info. it's actually only one check box on the continuous form.

There are 4 choices and the user have to check the correct one....
schroep
I don't understand. If there are four choices and the user is selecting one, then there are four checkboxes, right?

Are you saying there are four RECORDS displayed using a continuous form? And each RECORD has one checkbox, corresponding to a Yes/No field in the table? And you want to set the other three RECORDS to "no" when one of the RECORDS is checked to "yes"?

If that's the case, you want to run an UPDATE query in the AfterUpdate event of the checkbox field to set all the other RECORDS to no.

But I have to say, this seems like strange design. Why are you using a continuous form for this?
sugarcane
What you explained is exactly how I have it set-up.

I'm creating a quiz database where I can enter a hugh amount and be able to go in and tick a few quizzes that I want to print (rather than retying/rearranging them in MS Word). The reason why I have the check box is to remember which is the correct answer.

It's not crucial that I have this done because I will be the only one using it - but thought it would be good to have in order to prevent checking two.

Attached is a pic so you can see what I'm doing....

Thanks for your help!
schroep
Open your continuous form.

Create an AFTERUPDATE event for the CorrectAns field.

CODE
CurrentProject.Connection.Execute "UPDATE tablename SET fieldname=0 WHERE quesidfieldname=" & Me.quesidcontrolname & " And answeridfieldname<>" & Me.answeridcontrolname

Me.Requery

tablename = the name of the table you are updating (the answers table)
fieldname = the name of the yes/no field in that table
quesidfieldname = the name of the field in the table that contains the QuestionID
questidcontrolname = the name of the (hidden?) control on your form that contains the current QuestionID
answeridfieldname = the ID field that uniquely identifies this answer (for this question) in your table
answercontrolname = the control on your form (likely hidden) that contains the ID of the current answer record
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.