Solved Looking to hide ribbon for forms but not reports (1 Viewer)

NeilT123

Member
Local time
Today, 11:24
Joined
Aug 18, 2022
Messages
30
Good afternoon, I have a database that has evolved over several years and due to a change in my working habits I need it to play nicely on my laptop which is a smaller screen than the database was developed in.

In due course I will be looking to try and retrofit Form Resizing but initially I would like to hide the ribbon for forms (in form view) but not reports so is there an easy way to set the ribbon to hidden for all my forms but visible if I open a report and also visible if I open a form in design view? The database has about 50 forms/subforms and a similar number of reports so I would prefer not to have to add code to each form and report if possible.

Thank you in advance for any input.
 
In a standard module.
Code:
Public Sub HideRibbon()
  DoCmd.ShowToolbar "Ribbon", acToolbarNo    'Hides the full toolbar
End Sub
Public Sub ShowRibbon()
  DoCmd.ShowToolbar "Ribbon", acToolbarYes   'Show
End Sub

Then in every form
Code:
Private Sub Form_Close()
  ShowRibbon
End Sub

Private Sub Form_Load()
  HideRibbon
End Sub

Even with 50 Forms that should take max 30 seconds per form. So 25 minutes max. Probably more like 15 max.

If you find it tedious you could write code using extensibility to do this and write this into all codes. But even for me that would take more than 15 minutes to write that code, even though I can build complete class modules through code.

But if interested in learning how to write code to write code, I can show you how to do it. But you have to
Do the following in code
loop all forms
1. See if the Load event exists. If not create the load event.
2. Add code to the load event
3. see if the close event exist, if not create it
4. add code to the load event

Loop all forms
1. open in design view
2. add "[Event Procedure]" to Load and Close properties
3. Save the form
 
I use a slight variation on the same theme which is fast and may be less code.
Hide the ribbon in an autoexec macro then open the startup form. The ribbon remains hidden so no additional code is needed here.

For reports there are several choices designed to allow printing
1. If using Report View, add a Print button to the report. No ribbon needed
2. When using Print Preview, show the ribbon using the Report_Open event and hide it again when the report closes.

You can find both approaches in action in my example app

In addition, if you want code to resize all your forms automatically for the smaller monitor, the same example app includes all code needed to do this
 
Last edited:

Users who are viewing this thread

Back
Top Bottom