Radio Button Does Not Show Selection After Form is Closed

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,160
Office Version
  1. 365
Platform
  1. Windows
I have a form with 4 different option groups and contains radio buttons (Yes, No, TBD). I select the values for a record, save it, close the form and reopen the record, but my selection does not show on the form. However, it is showing in the source Table. How can I fix this?

Most of the option groups has a macro associated to it. I'm not sure, but do I need to modify the macro to visibile or something? When I select a radio button and save the form it should save my selection whenever I open the record. Below is an example for one of the radio button option group.

Code:
Private Sub Frame103_AfterUpdate()
Select Case Me![Frame103]
    
        Case 1
            Me![Text101] = "Y"
            Me.Frame112.Locked = False
                       
        Case 2
            Me![Text101] = "N"
            Me.Frame112 = 2
            Me.Frame112.Locked = True
            
        Case 3
            Me![Text101] = "TBD"
            Me.Frame112 = 3
            Me.Frame112.Locked = True
    
    End Select
        
End Sub
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I can't tell by the name of your Controls what's what. Which one is the Radio Button? What is the Record Source?

Side note, please name your Controls something meaningful. This will help you and anyone trying to help you...
My Database Standards… « Gina's Coffee Shop

Thanks for your site. I didn't know you were a MVP!

In my Form:

Frame103 is one option group that has radio buttons "Yes" "No" and "TBD"

Frame112 is the second option group that has radio buttons "Yes" "No" and "TBD"

Neither Frame has a Control Source. Frame103 is the only one that has the AfterUpdateMacro which I provided in my original post.

Text101 is set to invisible and has the Control Source for Frame103. Text313 is set to invisible and has the Control Source for Frame112. The Control Source for Text101 and Text313 is for field names CBE and SBE in my Table, respectively. Furthermore, both CBE and CBE fields in the Table has lookups of another table that has the values "Y" "N" and "TBD". I have it set this way so that my Table gives text values (Y, N, TBD) rathern than numerical values. In addition, the lookup table is good because it'll allow any updates or different text values if needed.

Let me know if this make sense, if not then I can change the control names or if you have any further questions.

There are 2 issues:

1) In the interface of the Form, I can make the according selection with the VBA code I posted. However when I save the Form (data entry Form) close it and then re-open it doesn't show the selections I had saved. However, the Table does show the values that I had orignally selected.

2) When I look at my Table, the answer in Frame112 does not reflect the correct answer I picked in my Form. No matter if I select "No" or "TBD" for Frame112 the Table always shows a "Y".
 
Last edited:
Upvote 0
Well, without reading past the fourth line I see your problem. In order for it to retain that entry it needs a Control Source... it has to be bound to a field in your Table. Your Macro takes care of putting the value in the Table but the Control doesn't know that. And, once you bind the Control you won't need the Macro. This probably also explains the incorrect values being posted to the Table. Think about... technically, the records not saved yet so it's pot luck as to what will get entered, last value selected or first value in the list. Bind it and both issues should go away.

P.S. Yep, been I was humbled by the award 5 years ago and till eel humbled.
 
Upvote 0
Well, without reading past the fourth line I see your problem. In order for it to retain that entry it needs a Control Source... it has to be bound to a field in your Table. Your Macro takes care of putting the value in the Table but the Control doesn't know that. And, once you bind the Control you won't need the Macro. This probably also explains the incorrect values being posted to the Table. Think about... technically, the records not saved yet so it's pot luck as to what will get entered, last value selected or first value in the list. Bind it and both issues should go away.

P.S. Yep, been I was humbled by the award 5 years ago and till eel humbled.

If I put the Control Source for both Frames, then the interface will behave funny since I have the macro (i.e. selection won't show in Frame103). I think I need the macro, because it stores text values(Y, N, TBD) instead of numerical values (1, 2, 3) in the Table AND because the macro designed so that:

1) When a user selects "Yes" in Frame103, they can select any three options (Yes, No, TBD) in Frame112.
2) When a user selects "No" in Frame103, it automatically locks on the "No" button in Frame112
3) When a user selects "TBD" in Frame103, it automatically locks on the "TBD" button in Frame112

I borrowed the method from here:

http://bytes.com/topic/access/answers/676707-how-change-option-group-value-text

P.P.S. As spiderman once said, "with great power, comes great responsibility" :P
 
Last edited:
Upvote 0
Hmm, but I see a Select Case statement, not a Macro. Are you combining the Select Case with the Macro? That said, you could accomplish the locking within the Select Case if that is all you Macro is doing AND you are also using the Select Case.
 
Upvote 0
Hmm, but I see a Select Case statement, not a Macro. Are you combining the Select Case with the Macro? That said, you could accomplish the locking within the Select Case if that is all you Macro is doing AND you are also using the Select Case.

The Select Case statement is a macro. What I posted is a macro, is it not? Where would you put the Select Case statement then? I followed the instructions on the link in my previous post.
 
Upvote 0
We could be having a terminology difference here. The Select Case statement would not be a Macro, it would code behind the After_Update event of the Frame. If you followed those instructions then that would be code, as in what you posted is Code. I thought you had a Macro in addition to the Code you posted. So, now that we have that straightened out here's the problem...

The Select Case is numeric unbound because you are storing text, they don't match so the Option Group can' show the value. could try putting some Code in the On_Current event of the Form, something like...

Code:
Select Case Me![Frame103]

Case 1
Me![Frame103] = 1

Case 2
Me![Frame103] = 2

Case 3
Me![Frame103] = 3

End Select
 
Upvote 0
We could be having a terminology difference here. The Select Case statement would not be a Macro, it would code behind the After_Update event of the Frame. If you followed those instructions then that would be code, as in what you posted is Code. I thought you had a Macro in addition to the Code you posted. So, now that we have that straightened out here's the problem...

The Select Case is numeric unbound because you are storing text, they don't match so the Option Group can' show the value. could try putting some Code in the On_Current event of the Form, something like...

Code:
Select Case Me![Frame103]

Case 1
Me![Frame103] = 1

Case 2
Me![Frame103] = 2

Case 3
Me![Frame103] = 3

End Select

Looks like that didn't do anything when I put the code in the On_Current event. After I closed and re-opened the Form, my selection does not show on the Form. Another strange thing is before I close the Form, I scroll to the next record and the values I selected for the radio button shows for all the records. This shouldn't be happening. When I go to a new record the values should be empty, since no selection has been made for it.

You can mimic what I am trying to do by creating a Table and a option group on a Form with the radio buttons and see it for yourself.
 
Last edited:
Upvote 0
I *thought* that might happen but I was hoping. That is happening because they are not bound to any field. I don't need t see it I know what and why.
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top