How to get a Toggle Button to work

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that has a toggle button and when it is pressed an invisible
subform becomes visible.

However when the toggle button is released I want to make the subform
invisible again. I also want the toggle button to display the name ie

toggle button pressed out - button name = "abcd" Subform Hidden

toggle button pressed in - button name = "wxyz" subform visible

Can this be done without using code ie on the buttons property sheet?

The visible and invisible settings is not the problem but the button is!! or
should i say my lack of knowledge is !!

Any help or advice greatly appreciated.

Kind regards Colin
 
You will need to use code (or a convoluted macro).

When you depress the toggle button, it's AfterUpdate event fires. Set the
AfterUpdate property to:
[Event Procedure]

Then click the Build button (...) beside this.
Access opens the code window.
Set up your code to look like this:

Private Sub Toggle1_AfterUpdate()
Dim bShow As Boolean

bShow = Nz(Me.Toggle1.Value, False)
Me.[NameOfYourSubformControlHere].Visible = bShow
Me.Toggle1.Caption = IIf(bShow, "abcd", "wxyz")
End Sub
 
Can I ask how did you get the code to display a hidden subform? I've been
trying for ages!
 
Back
Top