Toggle Button

ocp&mcsd

The Hitman
Local time
Today, 08:09
Joined
Jan 25, 2006
Messages
113
Hi all,
I have a form with two subform on it and two toggle buttons.
Clicking each toggle button will open one of subform, and clicking it again will close that subform. But the problem is that I need to click the toogle button two time to open the sub form.
So, what is the problem??

This is the code under On Click event:
Private Sub Toggle0_Click()
If Me.TendComm_Label.Visible = False Then
Me.TendComm_Label.Visible = True
Me.TendComm.Visible = True
Else
Me.TendComm_Label.Visible = False
Me.TendComm.Visible = False
End If
End Sub

Private Sub Toggle1_Click()
If Me.AuthorizedSignature_Label.Visible = False Then
Me.AuthorizedSignature_Label.Visible = True
Me.AuthorizedSignature.Visible = True
Else
Me.AuthorizedSignature_Label.Visible = False
Me.AuthorizedSignature.Visible = False
End If
End Sub
 
Mark,

Those aren't subforms. They're two textboxes and their labels.

Set their Default properties to visible (or invisible).

On the buttons:

Code:
Private Sub Toggle0_Click()
  Me.TendComm_Label.Visible = Not Me.TendComm_Label.Visible
  Me.TendComm.Visible = Not Me.TendComm.Visible 
End Sub

Private Sub Toggle1_Click()
  Me.AuthorizedSignature_Label.Visible = Not Me.AuthorizedSignature_Label.Visible 
  Me.AuthorizedSignature.Visible = Not Me.AuthorizedSignature.Visible 
End Sub

hth,
Wayne
 
WayneRyan said:
Mark,

Those aren't subforms. They're two textboxes and their labels.

Dear sir,
I am sure they are subforms...
 
Mark,

You may have 2 subform on your Main form. However I agree with Wayne regarding your posted code;
"Those aren't subforms. They're two textboxes and their labels."

If you want to change the Source Object on the Main Form has a look at my sample. It also changes the label text. In kthis sample you can change the source either by toggle button or option group.
 

Attachments

Mark,

First Question:-
I got you Mr. ansentry
What does this mean?



Second Queston;
Did my sample solve your problem?
 
ansentry said:
First Question:-What does this mean?

I replaced the previous code with this:

Private Sub Toggle0_AfterUpdate()
Select Case Toggle0
Case True
Me.TendComm.Visible = True
Case False
Me.TendComm.Visible = False
End Select
End Sub

Private Sub Toggle1_AfterUpdate()
Select Case Toggle1
Case True
Me.AuthorizedSignature.Visible = True
Case False
Me.AuthorizedSignature.Visible = False
End Select
End Sub



ansentry said:
Second Queston;
Did my sample solve your problem?

Yes, I soved it.
Special thanks to you Mr. John
 
Why use 2 toggle button, try this;

Code:
Private Sub Toggle0_AfterUpdate()
   Select Case Toggle0
      Case True
          Me.TendComm.Visible = True
          Me.AuthorizedSignature.Visible = False

      Case False
         Me.TendComm.Visible = False
         Me.AuthorizedSignature.Visible = True

   End Select
End Sub

I am assuming that AuthorizedSignature & TendComm are the names of your subforms, if I am correct my I suggest that you give them names that identifies them e.g sfrmTrendComm or sfrmAuthorizedSignature
 
Last edited:
I didn't try this because now, I have 7 subforms....
Thanks again Mr. John

ansentry said:
Why use 2 toggle button, try this;

Code:
Private Sub Toggle0_AfterUpdate()
   Select Case Toggle0
      Case True
          Me.TendComm.Visible = True
          Me.AuthorizedSignature.Visible = False

      Case False
         Me.TendComm.Visible = False
         Me.AuthorizedSignature.Visible = True

   End Select
End Sub

I am assuming that AuthorizedSignature & TendComm are the names of your subforms, if I am correct my I suggest that you give them names that identifies them e.g sfrmTrendComm or sfrmAuthorizedSignature
 

Users who are viewing this thread

Back
Top Bottom