Switchboard Button to Open Sub-switchboard buttons

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,171
Office Version
  1. 365
Platform
  1. Windows
I think there is a simple answer to this, but my brain is just not functioning right now.

I created a switchboard form in Design View. I want to create a button called Reports. When the user clicks it, it should have a button for Report 1, button for Report 2, button for Report 3, etc. How can I make this happen?
 
What other buttons do you have on the switchboard?

Button for data entry form, search records, history log table, and exit application. Just need to have the Report button and it's 7 respective buttons.i will also have a back button once I am able to view the 7 buttons so it take me back to the main switchboard.
 
Last edited:
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Perhaps you could hide all the buttons when the Reports button is clicked and display your 7 report buttons and on your back button do the opposite (Hide report buttons and show switchboard buttons) that may give you the effect you're looking for.

HTH
Colin
 
Upvote 0
Perhaps you could hide all the buttons when the Reports button is clicked and display your 7 report buttons and on your back button do the opposite (Hide report buttons and show switchboard buttons) that may give you the effect you're looking for.

HTH
Colin

Yeah that will work too. So I will have 5 buttons on my switchboard (the ones I mentioned including the Reports button). So when the Reports button is clicked the 4 other buttons will turn invisible and my 7 report buttons will display. In additions, the back button will be disabled after I click it to go "back" to the 5 main switchboard buttons. Any codes to get me started?
 
Upvote 0
Try this, you will have to change the button control names to whatever you have called your buttons;

Put ths code in the forms 'On Load' event
Code:
Private Sub Form_Load()
'hide report buttons
Me.Report1.Visible = False
Me.Report2.Visible = False
Me.Report3.Visible = False
Me.Report4.Visible = False
Me.Report5.Visible = False
Me.Report6.Visible = False
Me.Report7.Visible = False
Me.BackButton.Visible = False
End Sub
Put this code on the 'Reports' button
Code:
Private Sub Reports_Click()
'display report buttons
Me.Report1.Visible = True
Me.Report2.Visible = True
Me.Report3.Visible = True
Me.Report4.Visible = True
Me.Report5.Visible = True
Me.Report6.Visible = True
Me.Report7.Visible = True
Me.BackButton.Visible = True
'hide switchboard buttons
Me.DataEntry.visible = False
Me.Search.visible = False
Me.HistoryLog.visible = False
Me.Exit.visible = False
Me.Reports.visible = False
End Sub
Put his code on the 'Back' button
Code:
Private Sub Back_Click()
'display switchboard buttons
Me.Report1.Visible = False
Me.Report2.Visible = False
Me.Report3.Visible = False
Me.Report4.Visible = False
Me.Report5.Visible = False
Me.Report6.Visible = False
Me.Report7.Visible = False
Me.BackButton.Visible = False
'display switchboard buttons
Me.DataEntry.visible = True
Me.Search.visible = True
Me.HistoryLog.visible = True
Me.Exit.visible = True
Me.Reports.visible = True
End Sub
HTH
Colin
 
Upvote 0
Hang on a minute, you cant hide a control that has focus, give me a minute and I'll have a look at the code.
 
Upvote 0
I have amended the code to change focus onto another control so the active control can be hidden;
Code:
Private Sub BackButton_Click()
'display switchboard buttons
Me.Report1.Visible = False
Me.Report2.Visible = False
Me.Report3.Visible = False
Me.Report4.Visible = False
Me.Report5.Visible = False
Me.Report6.Visible = False
Me.Report7.Visible = False

'display switchboard buttons
Me.cmdDataEntry.Visible = True
Me.Search.Visible = True
Me.HistoryLog.Visible = True
Me.cmdExit.Visible = True
Me.Reports.Visible = True
Me.cmdDataEntry.SetFocus
Me.BackButton.Visible = False
End Sub
Private Sub Form_Load()
'hide report buttons
Me.Report1.Visible = False
Me.Report2.Visible = False
Me.Report3.Visible = False
Me.Report4.Visible = False
Me.Report5.Visible = False
Me.Report6.Visible = False
Me.Report7.Visible = False
Me.BackButton.Visible = False
End Sub
Private Sub Reports_Click()
'display report buttons
Me.Report1.Visible = True
Me.Report2.Visible = True
Me.Report3.Visible = True
Me.Report4.Visible = True
Me.Report5.Visible = True
Me.Report6.Visible = True
Me.Report7.Visible = True
Me.BackButton.Visible = True
'hide switchboard buttons

Me.Search.Visible = False
Me.HistoryLog.Visible = False
Me.cmdExit.Visible = False
Me.cmdDataEntry.Visible = False
Me.Report1.SetFocus
Me.Reports.Visible = False
End Sub

Let me know if this works for you,

Colin
 
Upvote 0
I have amended the code to change focus onto another control so the active control can be hidden;
Code:
Private Sub BackButton_Click()
'display switchboard buttons
Me.Report1.Visible = False
Me.Report2.Visible = False
Me.Report3.Visible = False
Me.Report4.Visible = False
Me.Report5.Visible = False
Me.Report6.Visible = False
Me.Report7.Visible = False

'display switchboard buttons
Me.cmdDataEntry.Visible = True
Me.Search.Visible = True
Me.HistoryLog.Visible = True
Me.cmdExit.Visible = True
Me.Reports.Visible = True
Me.cmdDataEntry.SetFocus
Me.BackButton.Visible = False
End Sub
Private Sub Form_Load()
'hide report buttons
Me.Report1.Visible = False
Me.Report2.Visible = False
Me.Report3.Visible = False
Me.Report4.Visible = False
Me.Report5.Visible = False
Me.Report6.Visible = False
Me.Report7.Visible = False
Me.BackButton.Visible = False
End Sub
Private Sub Reports_Click()
'display report buttons
Me.Report1.Visible = True
Me.Report2.Visible = True
Me.Report3.Visible = True
Me.Report4.Visible = True
Me.Report5.Visible = True
Me.Report6.Visible = True
Me.Report7.Visible = True
Me.BackButton.Visible = True
'hide switchboard buttons

Me.Search.Visible = False
Me.HistoryLog.Visible = False
Me.cmdExit.Visible = False
Me.cmdDataEntry.Visible = False
Me.Report1.SetFocus
Me.Reports.Visible = False
End Sub

Let me know if this works for you,

Colin

Thank you so much. Works like a charm :)
 
Upvote 0
Code:
Me.cmdDataEntry.SetFocus

Me.Report1.SetFocus


For understanding purposes - what does the above codes do?
 
Upvote 0
Code:
Me.cmdDataEntry.SetFocus

Me.Report1.SetFocus


For understanding purposes - what does the above codes do?

When you click the report button (On Switchboard), it has 'Focus', and therefore it cannot be hidden while it has focus. So if you move the focus to one of the buttons you made visible (Report1 in this case) then the focus has been removed from the report button(On Switchboard), enabling it to be hidden. Same goes for the Back button, it needs to move the focus onto another button (cmdDataEntry in this case) so it can be hidden.

If this doesn't make sense post back and I'll try another way of explain it, or even comment out those lines and see what happens.

HTH

Colin
 
Upvote 0
When you click the report button (On Switchboard), it has 'Focus', and therefore it cannot be hidden while it has focus. So if you move the focus to one of the buttons you made visible (Report1 in this case) then the focus has been removed from the report button(On Switchboard), enabling it to be hidden. Same goes for the Back button, it needs to move the focus onto another button (cmdDataEntry in this case) so it can be hidden.

If this doesn't make sense post back and I'll try another way of explain it, or even comment out those lines and see what happens.


HTH

Colin

Makes totally sense now. Thanks for the explanation.
 
Upvote 0

Forum statistics

Threads
1,215,153
Messages
6,123,325
Members
449,097
Latest member
gameover8

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top