Disable Design View from Report (1 Viewer)

GrahamUK33

Registered User.
Local time
Today, 20:58
Joined
May 19, 2011
Messages
58
I have hidden the ribbon and database window adding the following code to the OnLoad event of a SplashScreen Access 2013 Form.

DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.RunCommand acCmdWindowHide

I would like to remove/disable the option to select 'Design View' (right-click menu) on a Report, is there any code that I can add the OnLoad event for a Report?
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:58
Joined
May 7, 2009
Messages
19,229
it is either all or none, meaning you disable it in all.
you put this in a Standard Module:
Code:
Public Function fncDisableDesignView()
On Error Resume Next
    Dim cb As CommandBar
    Dim cbCtl As CommandBarControl
    For Each cb In CommandBars
        If cb.Type = msoBarTypePopup Then
            For Each cbCtl In cb.Controls
                If cbCtl.Caption = "&Design View" Then
                    cbCtl.Enabled = True
                    cbCtl.Visible = False
                Else
                    cbCtl.Visible = True
                End If
            Next
        End If
    Next
    Set cb = Nothing: Set cbCtl = Nothing
End Function


create an AutoExec Macro that will call the function (RunCode fncDisableDesignView() ).

in order to get the Design View again use the bybass key (holding Shift Key while your db is opening).
 

GrahamUK33

Registered User.
Local time
Today, 20:58
Joined
May 19, 2011
Messages
58
Thanks @arnelgp this is just what I am after, but the code comes up with Error 2001, is there something that needs to be added to the code to solve the error?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:58
Joined
May 7, 2009
Messages
19,229
On vba add Reference to Microsoft Office xx.x Object Library. Should have said that earlier.
 

isladogs

MVP / VIP
Local time
Today, 20:58
Joined
Jan 14, 2017
Messages
18,209
Are you aware that if you save your db as an ACCDE for distribution, design view is automatically disabled (as well as removing the code from prying eyes)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:58
Joined
May 7, 2009
Messages
19,229
Goto vba (Alt-F11) on menu, tools, reference. Scroll and tick Microsoft Office xx.x Object Library. Xx.x means the version of office installed on your pc.
 

GrahamUK33

Registered User.
Local time
Today, 20:58
Joined
May 19, 2011
Messages
58
Goto vba (Alt-F11) on menu, tools, reference. Scroll and tick Microsoft Office xx.x Object Library. Xx.x means the version of office installed on your pc.

Will this need to be done on 'all' PCs that want to use the database? or will this setting be saved within the .accdb file?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:58
Joined
May 7, 2009
Messages
19,229
It will be saved with the db u will distribute. Im not sure if you will stll need to do this on machine with different office version as yours.

Also on Vba before you distrib your db make sure you add password to your code (on vba menu, property). So no one can modify your code.
 

GrahamUK33

Registered User.
Local time
Today, 20:58
Joined
May 19, 2011
Messages
58
Are you aware that if you save your db as an ACCDE for distribution, design view is automatically disabled (as well as removing the code from prying eyes)

Thanks @ridders I will bear this in mind.
 

isladogs

MVP / VIP
Local time
Today, 20:58
Joined
Jan 14, 2017
Messages
18,209
Although the MS Office reference is very useful for added functionality, it is as arnelgp stated version specific. In other words, it needs to be adjusted for each Access version in use

If you convert to ACCDE, design view is removed automatically without needing that particular reference
 

Users who are viewing this thread

Top Bottom