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.Examples of MS Access DateDiff function used in query and VBA code
2.MS Access DateDiff function
3.How to find out your computer name and username by VBA
4.Examples of MS Access DatePart function
5.MS Access DatePart function
6.Examples of MS Access DateAdd function
7.MS Access DateAdd function
8.IIF function basics - the CASE statement of MS Access
9.MS Access Date Expression
10.Solved: MS Access error "The text is too long to be edited"
11.Create MS Access Combo Box essential properties by VBA code
12.Create MS Access Combo Box essential properties manually
13.How to do text search in MS Access programmatically
14.Solved - the size of the Access query result is larger than the maximum size of a database (2 GB)
15.How to easily get a list of field names in MS Access
16.How to count distinct records in MS Access
17.How to do transaction based processing in MS Access
18.How to open a document (local/network file or web page) from MS Access
19.How to use ADOX to create unique composite index - the VBA approach
20.How to do cross-table update queries in MS Access - the right way
21.Three efficient ways to get the number of records by using VBA
22.How to create a composite unique index (not as a primary key) in MS Access
23.Use VBA to get the correct number of records in a Recordset object
24.Disable Access Prompt when a record is changed, table deleted, or action queries run
25.How to hide and unhide a MS Access object
26.How to return multiple values from a VBA function (Part 3)
27.How to return multiple values from a VBA function (Part 2)
28.How to return multiple values from a VBA function (Part 1)
29.Three ways to programmatically duplicate a table in MS Access by VBA
30.Create a DLL by CSharp or VB.Net for VBA
31.How to correctly reference and call a DLL
32.How to register a C# or VB.Net DLL
33.Email address validation by Regular Expressions using VBA
34.Fix MS Access error: Query must have at least one destination field
35.How to Change Query Timeout Value for MS Access SQL Queries
36.What is Northwind Traders database

Copyright © 2024 GeeksEngine.com. All Rights Reserved.

This website is hosted by HostGator.

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