Solved

MS ACCESS Option Group with radio buttons linked to table columns

Posted on 2011-09-02
11
638 Views
Last Modified: 2013-11-27
I created an option group with 2 radio buttons. Each radio button should be a field in the table.
Frame0
   Admit?
   Re-Admit
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,
Audrey
0
Comment
Question by:audreymjhha
11 Comments
 
LVL 61

Expert Comment

by:mbizup
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.  
0
 
LVL 57
ID: 36474770
Audrey,

  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
  Else
      Me.Admit = False
      Me.Re-Admit = True
 End If

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

Jim.
0
 

Author Comment

by:audreymjhha
ID: 36474801
How am I linking the value to the database?
0
 

Author Comment

by:audreymjhha
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?
0
 
LVL 119

Expert Comment

by:Rey Obrero
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¢
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 57
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.

Jim.
0
 
LVL 57

Accepted Solution

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

Jim.
0
 

Author Comment

by:audreymjhha
ID: 36475010
I get an error message "You cannot assign a value to this object".
0
 
LVL 57
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?

Jim.
0
 

Author Closing Comment

by:audreymjhha
ID: 36475758
Thank you helping me!
0
 
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.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

947 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now