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 think you have so much going on here, it is very hard to tell what is connected to what, and what should impact what without actually seeing the database and Form you are working on. I think the best way to help you would be the following:

1. Remove any sensitive data from your database, and upload a copy of your database to a file sharing site for me to download
2. Provide a real simple example (step-by-step) of what you are trying to do, and what should happen behind the scenes


Then, I can work in the exact same setup you have, see what is happening, and see what needs to be done to get it to work the way you like.

I won't be able to download the database until I am at home later tonight.


What'a a good/free site to use for uploading?
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I am also reversing the code so that if Frame112 was selected then the following actions need to be done to Frame103 (see below), however, it's not working exactly, because If I select "Yes" in Frame112, and "No" in Frame103, the "Yes" automatically switches to "No" in Frame112 to match the Frame103_AfterUpdate code.

Code:
Private Sub Frame112_AfterUpdate()
    Select Case Me![Frame112]
        Case 1
            Me![Text111] = "Y"
            Me.Frame103.Locked = False
            Me![Text101] = "TBD"
        Case 2
            Me![Text111] = "N"
            Me.Frame103 = 2
            Me.Frame103.Locked = True
            Me![Text101] = "N"
        Case 3
            Me![Text101] = "TBD"
            Me.Frame103 = 3
            Me.Frame103.Locked = True
            Me![Text101] = "TBD"
                                
End Select
End Sub
 
Upvote 0
Just post the link here to this thread.
 
Upvote 0
OK. I am glad I can see your database, because it is definitely not designed the way I expected. I think you are making things a bit harder for yourself by having both Option Groups and Text Boxes associated with the same field you are trying to update back on your table. This really isn't the recommended way of going about things, and makes things a bit harder and messier, as you see.

If you are going to use an Option Box, this is the more recommended way of going about it: The Access Wizard

You might also want to approach this in a different manner. You might be able to get rid of both your Option Groups and Text boxes and replace them with Combo Boxes instead. Then you do not have to deal with the "numbers", if that is the issue for you. You can even make your Combo Box options dependent on other Combo Box selections, as mentioned here: Basing one combo box on another - Access

Whatever method you choose, I would recommend getting rid of the text boxes, so you are just dealing with Option Groups (and binding them) or Combo Boxes.

If you really want to continue on the road you are on, please walk me through a simple example, telling me what values you are picking on your Form, and what should be happening to the table behind the scenes. Now that I have the Form in front of me, it will make more sense now. I tried looking back at your previous comments, but there may be some disparity in some of the posts (or maybe lack of clarity or complete details), so I want to make sure that I do exactly what you are doing to see the results you are talking about.
 
Upvote 0
OK. I am glad I can see your database, because it is definitely not designed the way I expected. I think you are making things a bit harder for yourself by having both Option Groups and Text Boxes associated with the same field you are trying to update back on your table. This really isn't the recommended way of going about things, and makes things a bit harder and messier, as you see.

If you are going to use an Option Box, this is the more recommended way of going about it: The Access Wizard

You might also want to approach this in a different manner. You might be able to get rid of both your Option Groups and Text boxes and replace them with Combo Boxes instead. Then you do not have to deal with the "numbers", if that is the issue for you. You can even make your Combo Box options dependent on other Combo Box selections, as mentioned here: Basing one combo box on another - Access

Whatever method you choose, I would recommend getting rid of the text boxes, so you are just dealing with Option Groups (and binding them) or Combo Boxes.

If you really want to continue on the road you are on, please walk me through a simple example, telling me what values you are picking on your Form, and what should be happening to the table behind the scenes. Now that I have the Form in front of me, it will make more sense now. I tried looking back at your previous comments, but there may be some disparity in some of the posts (or maybe lack of clarity or complete details), so I want to make sure that I do exactly what you are doing to see the results you are talking about.

What I have is a Option Box/Radio Buttons on my Form (Procurement Log Form). Our focus should be on the CBE and SBE option boxes.

1) If you select the "No" radio button on the CBE, it automatically selects "No" radio button for SBE and locks the rest from selecting (this is working perfectly as designed);
2) If you select "TBD" radio button on the CBE, it automatically selects "TBD" radio button for SBE and locks the rest from selecting (this is working perfectly as designed);
3) If you select "Yes" radio button the CBE, it allows you to select either "Yes" "No" or "TBD" radio button for SBE (this is working perfectly as designed), HOWEVER, if you select "Yes" or "No" radio button for SBE, save the record and close it, it does not show it in the Table (01_FY2014_Procurement_Log). It only shows the incorrect answer, "TBD." I believe this is due to this:

Code:
Case 1
            Me![Text101] = "Y"
            Me.Frame112.Locked = False
            Me![Text111] = "TBD"

Run it thru and see for yourself. Let me know if you have any questions. Thanks.
 
Last edited:
Upvote 0
OK. Your "CBE" is associated with Frame103 and Text101 is the field that updates that "CBE_(Y/N)" field.
Now, if the user selects "TBD" for "CBE", you want them to be able to select any of the three options for "SBE", right?

Now, "SBE" is associated with Frame112 and Text111 is he field that updates the "SBE_(Y/N)" field.

Since you do NOT want to set the value of Text111 ("SBE_(Y/N)") when "Y" is selected for "CBE" (since they have the option of selecting any of the three), you do NOT want to update Text111 in this case.

So under Frame103, Case 1 should just look like this:
Code:
Case 1
    Me![Text101] = "Y"
    Me.Frame112.Locked = False
and that's it, no mention of Text111 under Case 1 here. That will updated under the Frame112_AfterUpdate event.

Your Frame112_AfterUpdate looks rather odd to me:
Code:
Private Sub Frame112_AfterUpdate()
    Select Case Me![Frame112]
        Case 1
            Me![Text111] = "Y"
            Me.Frame103.Locked = False
            Me![Text101] = "TBD"
Look what you have going on here. If your Select "Y" for "CBE", and then "Y" for "SBE", you last line above will set Text101 ("CBE") back to "TBD". Is that really what you intended to do?
 
Upvote 0
OK. Your "CBE" is associated with Frame103 and Text101 is the field that updates that "CBE_(Y/N)" field.
Now, if the user selects "TBD" for "CBE", you want them to be able to select any of the three options for "SBE", right?

Now, "SBE" is associated with Frame112 and Text111 is he field that updates the "SBE_(Y/N)" field.

Since you do NOT want to set the value of Text111 ("SBE_(Y/N)") when "Y" is selected for "CBE" (since they have the option of selecting any of the three), you do NOT want to update Text111 in this case.

So under Frame103, Case 1 should just look like this:
Code:
Case 1
    Me![Text101] = "Y"
    Me.Frame112.Locked = False
and that's it, no mention of Text111 under Case 1 here. That will updated under the Frame112_AfterUpdate event.

Your Frame112_AfterUpdate looks rather odd to me:
Code:
Private Sub Frame112_AfterUpdate()
    Select Case Me![Frame112]
        Case 1
            Me![Text111] = "Y"
            Me.Frame103.Locked = False
            Me![Text101] = "TBD"
Look what you have going on here. If your Select "Y" for "CBE", and then "Y" for "SBE", you last line above will set Text101 ("CBE") back to "TBD". Is that really what you intended to do?

I think you are misunderstanding me again. I'll try to approach this a different way.

1) If a user selects "No" for "CBE" then it should lock on "No" for "SBE"

2) If a user selects "TBD" for "CBE then it should lock on "TBD" for "SBE"

3) If a users selects "Yes" for "CBE" then any of the three options ("Yes","No", "TBD") should be allowed to be selected. The problem with my code is with this one only. Try this on the database yourself. Click "Yes" for "CBE" then select "No" for "SBE. Save the record. Now open the table 01_FY2014_Procurement_Log. What does it record for "SBE"? Try another scenario in the Form again. Select "Yes" for "CBE" and then select "Yes" for "SBE". Save the record. What do you see in the table now? I

t's not recording the correct selection, it puts "TBD" for the SBE field in the table even though you select "No" in the first case, or "Yes" in the second case.
 
Upvote 0

Forum statistics

Threads
1,215,368
Messages
6,124,520
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