MS ACCESS Option Group with radio buttons linked to table columns

Posted on 2011-09-02
Medium Priority
Last Modified: 2013-11-27
I created an option group with 2 radio buttons. Each radio button should be a field in the table.
I had this working as stand alone buttons but I need to modify so only one radio button can be selected. How do I capture the value selected within the option box so I can store the value in a table.

Thank you,
Question by:audreymjhha
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 61

Expert Comment

ID: 36474763
Option groups work a little differently that single radio buttons or checkboxes.

With single radio buttons or checkboxes, the valkues are stored in seperate fields.

An option group on the other hand is bound to a single field in your table.  The value of your option group reflects which choice was made.  Each radio button or check box option has a value (1,2,3,4, etc)  that is the value that is stored in your underlying field.  
LVL 58
ID: 36474770

  You really can't do this with a group that's bound as a group represents a single value, so you can only be bound to one field.

  That also indicates it's probably a bad idea to have your admit/re-admit flag as two fields, but you can do it by:

1. Leave your group unbound.

2. In the forms BeforeUpdate event to:

   If Me.<Group control name> = 1 then
      Me.Admit = True
      Me.Re-Admit = False
      Me.Admit = False
      Me.Re-Admit = True
 End If

  Make sure you use the actual control name and values you expect.


Author Comment

ID: 36474801
How am I linking the value to the database?
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.


Author Comment

ID: 36474836
I tried this code but I received an error message "object required".

Private Sub Frame0_AfterUpdate()

If Me.Frame0.Value = 0 Then
   tblmain.[Admit?] = "Y"
   End If

End Sub

If the user selects the Admit radio box, I was trying to put a "Y" into the field for that record. Is there different logic I can use?
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36474838
it helps to make a well design table if you will define the purpose of the field.
 what is the field "Admit" for ?
 what is the field "Re-Admit" for ?

depending on the usage/definition of the field, you might end up using a single field with "Admit" or "Re-Admit" as the values...

my 0.2¢
LVL 58
ID: 36474842
<<How am I linking the value to the database? >>

  Your doing it with code rather then through the built-in functionaility of a control.

LVL 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 36474853
If Me.Frame0.Value = 0 Then
   Me.Admit = "Y"
   Me.ReAdmit = "N"
   Me.Admit = "N"
   Me.ReAdmit = "Y"
End If


Author Comment

ID: 36475010
I get an error message "You cannot assign a value to this object".
LVL 58
ID: 36475122
Is "Admit" and "ReAdmit" the actual fields names in the table?   And are those fields in the forms recordsource? And last, you don't have any controls by that name?


Author Closing Comment

ID: 36475758
Thank you helping me!
LVL 31

Expert Comment

by:Helen Feddema
ID: 36480603
You may have a control with the same name as its bound field, which can cause reference errors.  It is best to give controls the appropriate prefixes, to avoid this problem.

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

762 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