MS Access - Option Group CHECK BOX HELP PLEASE.
My name is Jenny. I could not figure out how to do this, so please help me to figure it out.
I created an Option Group with 4 check boxes, 1st Checkbox is "All", 2nd is "Baseball", 3rd is "Soccer", and 4rd is "Bowling".
When you click on "All", the other three checkboxes show checkmarks automatically.
Is there any way to do that in MS Access?
Thanks.
I do not believe that you can do that with an Option Group for they are not designed to do that.
You would have to remove the option group and account for all four of the check marks [yes = -1, no = 0] via code for each check boxes and that is a lot of work. Multiple selections for what you want kinda defeats the purpose of an option group.
Your code for the option group should take the value of the "All" check box and perform your function based on performing the task for all three of the choices when "All" is checked.
Most folks use a Case Statement with their option groups to handle each value which depends on which check box is selected.
Also, you should delete your other two posts which are redundant to the forum.
I will follow your idea by deleting...
I think using Case statement is logical in this case. But I don't know how to do this? can you please provide me the code?
I am newbie in MS Access, please help.
Thanks.
ghudson said:
I do not believe that you can do that with an Option Group for they are not designed to do that.
You would have to remove the option group and account for all four of the check marks [yes = -1, no = 0] via code for each check boxes and that is a lot of work. Multiple selections for what you want kinda defeats the purpose of an option group.
Your code for the option group should take the value of the "All" check box and perform your function based on performing the task for all three of the choices when "All" is checked.
Most folks use a Case Statement with their option groups to handle each value which depends on which check box is selected.
Also, you should delete your other two posts which are redundant to the forum.
You can do it with ordinary check boxes and a little code
Hi Jenny,
There are probably several ways of doing this. The only way I know however, involves some VB code. Here's what to do.
First of all, you'll proably need to delete the option group and the controls inside it. Things often behave oddly inside option groups.
Now choose the Check Box control from the Toolbox (it's the square box with the tick inside) and draw four check boxes onto your form. Set the captions, then, if you like, draw an ordinary border round them so as they'll look like a group.
Next, you should name the four check boxes. Right click over the square tick box you captioned "All" and choose "Properties" from the bottom of the popup menu. The Properties popup will appear. Turn to the "Other" tab of the popup, and type "chkAll" in the "Name" cell at the top of the list.
Now move to the "Baseball" check box, and repeat , this time using the name "chkBaseball". And so on, for "chkSoccer" and "chkBowling" too.
Now return to the "All" checkbox, right click on the tick box, choose "Properties" from the popup menu, and turn to the Event tab of the Properties popup. The second cell down should be captioned "After Update". When you click in this cell, a "list button" - a little arrow head - should appear at the right-hand end of the cell. Click on this and select [Event Procedure]. Now click on the [...] button to the right of the list button. A new window will open.
Look for the text:
Code:
Private Sub chkAll_AfterUpdate()
End Sub
Paste the following code between the first and second lines:
Code:
If Me.chkAll = True Then
Me.chkBaseball = True
Me.chkSoccer = True
Me.chkBowling = True
End If
The text should now look like this:
Code:
Private Sub chkAll_AfterUpdate()
If Me.chkAll = True Then
Me.chkBaseball = True
Me.chkSoccer = True
Me.chkBowling = True
End If
End Sub
Now move up to the menu bar of the Microsoft Visual Basic window and choose:
File, Close and Return to Microsoft Access.
Run the form and test your check boxes. With any luck they'll work.
This is all a bit of a fuss though. Maybe someone else will suggest a better way of doing it.
The attached sample shows how to use the Select Case for the option group named ogType. In the option groups AfterUpdate event a message box will display which sport the user selected. You will have to decide what to do depending on which option group is selected and when it will happen.
No, You can’t do this in an option group, more correctly called “Radio buttons “ As the purpose Is to allow one, and only one selection.
However you can do it with just four check boxes directly placed on your form. Place four check boxes on your form, Chk1, Chk2, Chk3 & Chk4 and use the following code, I have written code for chk1 and chk2 You can modify the code shown for Chk3 & Chk4
Code:
Private Sub chk1_Click()
If chk1 = True Then
chk2 = True
chk3 = True
chk4 = True
Else
chk2 = False
chk3 = False
chk4 = False
End If
End Sub
Private Sub chk2_Click()
If chk2 = True Then
chk1 = False
chk3 = False
chk4 = False
Else
chk1 = True
chk3 = False
chk4 = False
End If
End Sub
Woh, it worked....
WOH WOH WOH....
I like the way you showed me. It was in detailed.
However, It didn't store the value in table. I tried to modify from control source, but it didn't work.
Thanks.
adam_fleck said:
Hi Jenny,
There are probably several ways of doing this. The only way I know however, involves some VB code. Here's what to do.
First of all, you'll proably need to delete the option group and the controls inside it. Things often behave oddly inside option groups.
Now choose the Check Box control from the Toolbox (it's the square box with the tick inside) and draw four check boxes onto your form. Set the captions, then, if you like, draw an ordinary border round them so as they'll look like a group.
Next, you should name the four check boxes. Right click over the square tick box you captioned "All" and choose "Properties" from the bottom of the popup menu. The Properties popup will appear. Turn to the "Other" tab of the popup, and type "chkAll" in the "Name" cell at the top of the list.
Now move to the "Baseball" check box, and repeat , this time using the name "chkBaseball". And so on, for "chkSoccer" and "chkBowling" too.
Now return to the "All" checkbox, right click on the tick box, choose "Properties" from the popup menu, and turn to the Event tab of the Properties popup. The second cell down should be captioned "After Update". When you click in this cell, a "list button" - a little arrow head - should appear at the right-hand end of the cell. Click on this and select [Event Procedure]. Now click on the [...] button to the right of the list button. A new window will open.
Look for the text:
Code:
Private Sub chkAll_AfterUpdate()
End Sub
Paste the following code between the first and second lines:
Code:
If Me.chkAll = True Then
Me.chkBaseball = True
Me.chkSoccer = True
Me.chkBowling = True
End If
The text should now look like this:
Code:
Private Sub chkAll_AfterUpdate()
If Me.chkAll = True Then
Me.chkBaseball = True
Me.chkSoccer = True
Me.chkBowling = True
End If
End Sub
Now move up to the menu bar of the Microsoft Visual Basic window and choose:
File, Close and Return to Microsoft Access.
Run the form and test your check boxes. With any luck they'll work.
This is all a bit of a fuss though. Maybe someone else will suggest a better way of doing it.
I am sorry for duplicate posts, but that was accidentally posted.
I clicked submit 3 times 'cause I din't know it went thru at 1st.
Sorry for that.
Please help.