Conditional Expression For Radio Button

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,171
Office Version
  1. 365
Platform
  1. Windows
I have two controls in my form and each has a radio button. In control 1 the user selects "No", then I want control 2 to automatically select "No" for the radio button. If the user selects "Yes" in control 1 then I want control 2 to do nothing and have the user the option to pick "Yes" or "No"

Will I have to build IIF statement in control 2 in the Validation Rule property? Or something in the Event properties?
 
Last edited:
I am a little confused as to what you are stating/asking:

Statement 1:
when I select "Yes" for CBE then click "No" for SBE, then the "Yes" for CBE changes to "No" automatically to correspond with "No" for SBE.


Statement 2:
If I select "Yes" for CBE I should be able to select any of the three option for SBE without my answer for CBE changing.

Are you saying this is what you want to happen (I hope not, as Statement 1 and Statement 2 seem to contradict each other), or are you saying Statement 1 is what is currently happening, and Statement 2 is what you actually want to happen (meaning you do NOT want the behavior you described in Statement 1)?
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I am a little confused as to what you are stating/asking:

Statement 1:


Statement 2:


Are you saying this is what you want to happen (I hope not, as Statement 1 and Statement 2 seem to contradict each other), or are you saying Statement 1 is what is currently happening, and Statement 2 is what you actually want to happen (meaning you do NOT want the behavior you described in Statement 1)?

Statement 1:

Using the most updated code that I last provided you. This is what happens:

1) I select "Yes" for CBE (Frame103) then;
2) I select "No" for SBE (Frame112)

Once I select "No" for SBE, the selection from "Yes" in CBE changes to "No" on it's own. This shouldn't happen.

--------------------------------------------------------------------------------------------------------------------------------------------------------

Again, here is another way of putting the 3 scenarios for Frame103_AfterUpdate:

1) When I select "Yes" for CBE (Frame103), I should have the option to select any of the three ("Yes" "No" "TBD") for SBE.
2) When I select "No" for CBE, it should lock on "No" for SBE and no other option can be selected
3) When I select "TBD" for CBE, it should lock on "TBD" for SBE and no other option can be selected

Now if the user does not click and make a selction for CBE (Frame103), and they skip it and click on SBE (Frame112), then the following 3 scenarios for Frame112_AfterUpdate should take place:

1) When I select "Yes" for SBE (Frame112), I should have the option to select any of the three ("Yes" "No" "TBD") for CBE.
2) When I select "No" for SBE, it should lock on "No" for CBE and no other option can be selected
3) When I select "TBD" for SBE, it should lock on "TBD" for CBE and no other option can be selected

This is all the possibilities that I need to make in my code. Let me know if you have any further querstion.

Thanks.
 
Upvote 0
Once I select "No" for SBE, the selection from "Yes" in CBE changes to "No" on it's own. This shouldn't happen.
That is because that is exactly what you are telling it to do in your code. See the last line of code from the excerpt of your Frame112_AfterUpdate block below:
Code:
Private Sub Frame112_AfterUpdate() 
    Select Case Me![Frame112] 
        Case 1 
            Me![Text111] = "Y" 
            Me.Frame103.Locked = False 
        Case 2 
            Me![Text111] = "N" 
            Me.Frame103 = 2 
            Me.Frame103.Locked = True 
            [COLOR=#ff0000]Me![Text101] = "N"[/COLOR]
You have the same thing under Case 3 also, where you are updating Text101. If you do not want the value of CBE changed after making a SBE selection, you need to remove the lines from Frame112_AfterUpdate that update Text101.
 
Last edited:
Upvote 0
That is because that is exactly what you are telling it to do in your code. See the last line of code from the excerpt of your Frame112_AfterUpdate block below:
Code:
Private Sub Frame112_AfterUpdate() 
    Select Case Me![Frame112] 
        Case 1 
            Me![Text111] = "Y" 
            Me.Frame103.Locked = False 
        Case 2 
            Me![Text111] = "N" 
            Me.Frame103 = 2 
            Me.Frame103.Locked = True 
            [COLOR=#ff0000]Me![Text101] = "N"[/COLOR]
You have the same thing under Case 3 also, where you are updating Text101. If you do not want the value of CBE changed after making a SBE selection, you need to remove the lines from Frame112_AfterUpdate that update Text101.

That didn't work either. Can you please try running the code in the database and see for yourself.

Here is what my code looks like so far, hopefully it's the same as what you said:

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

Private Sub Frame112_AfterUpdate()
    Select Case Me![Frame112]
        Case 1
            Me![Text111] = "Y"
            Me.Frame103.Locked = False
           
        Case 2
            Me![Text111] = "N"
            Me.Frame103 = 2
            Me.Frame103.Locked = True
          
        Case 3
            Me![Text111] = "TBD"
            Me.Frame103 = 3
            Me.Frame103.Locked = True
                                            
End Select
End Sub

I think it's because I need to tell somehow the code that CBE (Frame103) has precedence to be selected over SBE (Frame112). If the user does not select from CBE frame first then SBE frame should have precedence over CBE. I could be wrong.
 
Last edited:
Upvote 0
I think it's because I need to tell somehow the code that CBE (Frame103) has precedence to be selected over SBE (Frame112). If the user does not select from CBE frame first then SBE frame should have precedence over CBE. I could be wrong.
Yes, that certainly complicates things a bit. To tell you the truth, with all these conditions you have, and then having other fields other than the ones you are updating being the bound fields, there is a lot going on, and a lot of room for error.

In order to deal with the "order of precedence" things, I think you are going to have some IF statements under some of your case statements. You can check to see if a selection has been made in the Frames like this:
Code:
If Me.Frame103=0 Then
...
So, your code may start something like this:
Code:
Private Sub Frame112_AfterUpdate()
    
    Select Case Me![Frame112]
        Case 1
            Me![Text111] = "Y"
            ' Check to see if a value has been added for Frame103
            If Me.Frame103=0 Then
            ...
I hope that gets you started down the road you need to go. You might have to do a bit of trial and error to get it to work the way you want.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,545
Members
449,169
Latest member
mm424

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