How to get a Toggle Button to work

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
 
A

Allen Browne

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
 
G

Guest

Can I ask how did you get the code to display a hidden subform? I've been
trying for ages!
 

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

Similar Threads

toggle button coding 1
Toggle Button 1
Toggle Button not refreshing 1
Conflicting events 2
AllowEdits Toggle button not working 2
Toggle Button 1
Custom Images not showing in Ribbon toggle button 2
Calendar 2

Top