hide label\combo box depending on option group selection

M

Matt Williamson

I have an option group with 2 radio buttons for running reports. I have a
label and combobox that I want to toggle the visibility based upon which
radio button is selected. I can't figure out the best way to do it. Any
suggestions?

TIA

Matt
 
J

Jeff Boyce

Matt

First, consider your users. Folks tend to get nervous when things
disappear/re-appear. Another approach might be to enable/disable controls,
depending on what else is being done.

So, radio buttons are part of a group. You can add code behind that group
control that checks for which radio button (i.e., option) was selected and
resets the enabled property. It might look something like (untested, use
YOUR control names):

Select Case grpSomething
Case 1 'i.e., the first button/option was selected
Me!cboYourCombobbox.Enabled = False
Case 2 'i.e., the second ...
Me!cboYourCombobbox.Enabled = True
Case Else
MsgBox "Something's gone wrong -- there are only two radio
buttons!"
End Select

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
M

Matt Williamson

Jeff Boyce said:
Matt

First, consider your users. Folks tend to get nervous when things
disappear/re-appear. Another approach might be to enable/disable
controls, depending on what else is being done.

So, radio buttons are part of a group. You can add code behind that group
control that checks for which radio button (i.e., option) was selected and
resets the enabled property. It might look something like (untested, use
YOUR control names):

Select Case grpSomething
Case 1 'i.e., the first button/option was selected
Me!cboYourCombobbox.Enabled = False
Case 2 'i.e., the second ...
Me!cboYourCombobbox.Enabled = True
Case Else
MsgBox "Something's gone wrong -- there are only two radio
buttons!"
End Select

Thanks Jeff. I ended up doing this. works great.

I left the label visible and just toggled the enabled state of the combo. It
was really the AfterUpdate event that I was missing. I really didn't want to
code for all the mousedown, keydowns for both options.


Private Sub ReportSelect_AfterUpdate()

Select Case Me.ReportSelect.Value

Case 1
cboSalesOffice.Enabled = False
Case 2
cboSalesOffice.Enabled = True
End Select

End Sub

Matt
 
J

Jeff Boyce

Thanks for posting back with your solution/success. Other folks may be
looking for just this solution in the future.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top