Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

turning controls on/off based on choice 2

Status
Not open for further replies.

Greg553

MIS
Jul 6, 2009
60
US
hello
i am trying to figure out how to make a control active or inactive based on another control choice.

What I have is two group frames ( toggle buttons)
one is RUN/PASS the other two are Frame run and Frame pass, both wit toggle buttons in them.


What i'm trying to do is, when some one chooses run or pass in the first one , have the appropriate frame be active.

Say some one chooses the toggle run, than I want the RUN frame(toggles) to be active and the Pass ones inactive.

i know it is a conditional statement just not sure how to do this

thanks
 
I would use toggle buttons in an option group.... So based on the option group value in the after update event, make the controls 'inactive' / 'active'.

This depends on what you mean by active/inactive. Three properties come to mind, visible, enabled, and locked.
The Code below uses the visible property and only two controls, you may need more lines. Also you will need to know what numbers are assigned to which option group values... I assumed the values are 1 and 2 below. I used the Select Case Statement because I thought you may want to later add another option.... you could also use IF statement(s) rather than a Select Case statement.

Code:
Select Case Me!optGroupControl
Case 1 
     Me!txtControl1.Visible = True
     Me!txtControl2.visible = False
Case 2
     Me!txtControl1.Visible = False
     Me!txtControl2.visible = True
End Select
 
Thanks, that was what I was looking for.
Yes the values are 1 2

run = 1
Pass = 2

based on choice either the option run group or pass group is active.

 
Maybe this would help

I have an option group with two buttons, run and pass

there are two other option groups called RUN , Pass
in the Run group there are buttons for the hole run
in the pass group there are passing zones buttons a-h

this way if a person chooses a run play the pasing zones are not active so no input can be done

would that code do this
 
I didn't explicitly say it but you can add as many lines of code as you need for each control in the case blocks...
 
Here's another idea... have two tabs... One for runs and one for Passes.... Then just put the appropriate controls on each tab.
 
How are ya Greg553 . . .

Here's an example that disables the approriate option group (I think it looks better than showing & hiding.

In the code module of the form, copy/paste the following routine (Note: [blue]you![/blue] substitute proper OptionGroupNames in [purple]purple[/purple]).
Code:
[blue]Public Sub SetRunPass()
   Dim flg As Boolean
   
   flg = (Me.[purple][b]RunPassOptionGroupName[/b][/purple] = 1)
   
   Me.[purple][b]RunOptionGroupName[/b][/purple].Enabled = flg
   Me.[purple][b]PassOptionGroupName[/b][/purple].Enabled = Not flg

End Sub[/blue]
Next ... in the [blue]After Update[/blue] event of the RunPass Option Group and the [blue]On Load[/blue] event of the form, copy/paste the following line:
Code:
[blue]   Call SetRunPass[/blue]
Thats it ... perform your testing.

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Dear Greg553,

Have you tried using a list and based on the ListName.ListIndex i.e. a choice make visible or not.

Code:
Select Case ListYOURLISTNAME.ItemData(ListYOURLISTNAME.ListIndex)

Case "RUN"
          Button.Visible = True
          Button.Visible = True
Case "PASS"
          Button.Visible = false
          Button.Visible = false

end select

Button.Visible (Button can be substituted with any control you want.)

Hope this helps [smile]


Thank you,

Kind regards

Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top