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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle Button Show Hide

Status
Not open for further replies.

DaveyEdgar

Technical User
Jul 8, 2002
39
0
0
US
Greetings All :)

I have a toggle button named "tglshowhidestate"
I have a control on the same form called "txtstate"

I'd like the toggle button label to say "Show State", and when its pressed down, to unhide the "txtstate" control. At this point I want the label on the toggle button to change to "Hide State", and when that is clicked it will hide the "txtstate" control.

How do I do this?
Thanks a million!!
 
How are ya DaveyEdgar . . .

In form design view:
[ol][li]Set the [blue]Caption[/blue] property of [blue]tglShowHideState[/blue] to [purple]Show State[/purple].[/li]
[li]In the [blue]OnClick[/blue] event of [blue]tglShowHideState[/blue] copy/paste the following:
Code:
[blue]   Dim prp As Property
   
   Set prp = Me!tglShowHideState.Properties("Caption")
   
   If prp = "Show State" Then
      Me!txtState.Visible = True
      prp = "Hide State"
   Else
      Me!txtState.Visible = False
      prp = "Show State"
   End If[/blue]
[/li]
[li]Set the [blue]Visible[/blue] property of [blue]txtState[/blue] to [purple]No[/purple].[/li]
[li]Save the form & check it out . . .[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
Also,

1)Set the Caption property of "tglshowhidestate"
to Show State. (Caption.....Show State)
2)Set the Visible property of txtState to No. (Visible...No)
3)OnClick event of "tglshowhidestate" the following:

Private Sub tglshowhidestate_Click()
Select Case Me.tglshowhidestate.Value
Case 0
With Me.tglshowhidestate
.Caption = "Show State"
Me.txtstate.Visible = False

End With
Case -1
With Me.tglshowhidestate
.Caption = "Hide State"
Me.txtstate.Visible = True

End With
End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top