Custom Search
 


How to unselect radio buttons in MS Access after it has been selected



Radio buttons are useful MS Access user interface control element in Access Forms design. It is useful in that there is only one radio button can be selected at any time. So when you need the user to select only one choice from a group of options, use radio button. To create a group of radio buttons in Access, use the Option Group control.

The problem with Option Group radio buttons is that, once the user selected one radio button, it can't be deselected or unselected. Sometimes your application may require that none of these radio buttons should be selected. In this case, you need an easy way to let the user quickly unselect the selected radio button.

The way to solve this problem is add one line of VBA code to the double click event of the radio button control.

Below is a demo on how to unselect radio button in Access. We will create a group of three radio buttons - Egg, Milk, Bread. After finish, you should be able to select a radio button and if you double click the selected radio button, it's unselected.

Here are the steps to create a tiny VBA code for the On Dbl Click (on double click) event to deselect a radio button group.

Step #1: Create a new form in your Access database.

Open an empty Access application. On the left hand side menu, click Forms and then click New button.

Step #2: Add a new Option Group control on this form.

Select Option Group from within the Toolbox panel.

Add a new Option Group in Access

Step #3: Add three labels to the Option Group.

Click anywhere on the new form and Option Group Wizard is opened. Type in three label names (Egg, Milk, Bread). Click Finish to complete.

Add three labels to the Option Group in Access

The newly created Option Group looks like this:
Access Option Group Properties

Step #4: Open the control's Properties window and select Event tab.

Click the line surrounding the group and select Properties in the pop-up menu. Then click Event tab when the properties window comes up.

Access Option Group Double Click Event

Step #5: Select anywhere inside "On Dbl Click" event.

Click the button that has ... in it.

Step #6: Select Code Builder to open VBA editor.

This will open VBA code editor so you can add code in it.

Select VBA Code Builder

Step #7: Add the following code to the sub routine.

Add the following line of code into the double click event sub-routine.

Me.Frame0 = ""

This is how it looks like in VBA code editor:
VBA code editor

Step #8: View the form in Form View.

Save the VBA code and then go back the forms Design View and change it to Form View. Now select a radio button such as Egg.

Step #9: Double click any radio button to unselect them.

Now to unselect the radio button you have just selected, double click any radio button and the selection is dimmed, which means no radio button is selected.

Hope you enjoy this simple but very useful tip in Access form design.


Copyright© GeeksEngine.com



Other Recent Articles from the MS Access category:

1.How to easily get a list of field names in MS Access
2.How to count distinct records in MS Access
3.How to do transaction based processing in MS Access
4.How to open a document (local/network file or web page) from MS Access
5.How to use ADOX to create unique composite index - the VBA approach
6.How to do cross-table update queries in MS Access - the right way
7.Three efficient ways to get the number of records by using VBA
8.How to create a composite unique index (not as a primary key) in MS Access
9.Use VBA to get the correct number of records in a Recordset object
10.Disable Access Prompt when a record is changed, table deleted, or action queries run
11.How to hide and unhide a MS Access object
12.How to return multiple values from a VBA function (Part 3)
13.How to return multiple values from a VBA function (Part 2)
14.How to return multiple values from a VBA function (Part 1)
15.Three ways to programmatically duplicate a table in MS Access by VBA
16.Create a DLL by CSharp or VB.Net for VBA
17.How to correctly reference and call a DLL
18.How to register a C# or VB.Net DLL
19.Email address validation by Regular Expressions using VBA
20.Fix MS Access error: Query must have at least one destination field
21.How to Change Query Timeout Value for MS Access SQL Queries
22.What is Northwind Traders database

Copyright © 2014 GeeksEngine.com. All Rights Reserved.

This website is hosted by LunarPages.

No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it.

 
Home | Feedback | Terms of Use | Privacy Policy