UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Hiding Backstage Commands, Access 2016    
 
   
pere_de_chipstic...
post May 20 2019, 04:10 PM
Post#1


UtterAccess Editor
Posts: 10,497
Joined: 8-November 07
From: South coast, England


Hi All

I am trying to get to grips with the A2016 Ribbon Backstage. So far I have been able to hide all the Backstage controls and add various commands.

Currently I have various commands, including C&R, on a custom ribbon, which I would like to move to the backstage. However, I do want not the "Encrypt with Password" command, which appears on the same Backstage tab as the C&R command

I could hide the existing group, and add new controls, but it won't accept (e.g) <button idMso="FileCompactAndRepairDatabase" visible="true" label="Compact and Repair" /> and a C&R can't be instigated by calling a VBA function.

How can I either add an idMso="FileCompactAndRepairDatabase" command to the backstage or hide the "Encrypt with Password' command on the 'info' tab ?

TIA

--------------------
Warm regards
Bernie
Go to the top of the page
 
ranman256
post Jul 18 2019, 11:34 AM
Post#2



Posts: 902
Joined: 25-April 14



i have code to lock the shift and remove toolbars to keep Nosey Nellys out.
make a form with a box for the db path, then run:

DatabaseProtect.apDisableShift




CODE
Option Compare Database

Function apDisableShift() As Boolean
    'This function disable the shift at startup. This action causes
    'the Autoexec macro and Startup properties to always be executed.

    On Error GoTo errDisableShift

        Dim db As DAO.Database
        Dim prop As DAO.Property
        Const conPropNotFound = 3270
        Dim sProp As String
        
        Set db = OpenDatabase(CurrentProject.Path & "\" & [Forms]![frmMenu]![cmbDBName])
        Check4MdbProps db
        
        db.Properties("StartUpShowDBWindow") = False
        db.Properties("StartUpShowStatusBar") = False
        db.Properties("AllowFullMenus") = False
        'enable F11, ALT F11, etc. for short key
        db.Properties("AllowSpecialKeys") = False
        'allow Access Shortcut Menus. May be too severe
        db.Properties("AllowShortcutMenus") = False
        db.Properties("AllowToolbarChanges") = False
        
        sProp = "AllowByPassKey"
        db.Properties("AllowByPassKey") = False

        sProp = "AllowBreakIntoCode"
        db.Properties("AllowBreakIntoCode") = False
        
        apDisableShift = True
endit:
        'The function is successful.
        Exit Function

errDisableShift:
    If Err = 3270 Then    'Property not found
        Set prp = db.CreateProperty(sProp, dbBoolean, False)
        db.Properties.Append prp
        Resume Next
   Else
        MsgBox Err.Description & vbCrLf & "prop:" & sProp, , "apDisableProps:" & Err
        Resume Next  'endit
   End If
  
Resume


End Function

Function apEnableShift()
'This function enables the SHIFT key at startup. This action causes
'the Autoexec macro and the Startup properties to be bypassed
'if the user holds down the SHIFT key when the user opens the database.

    On Error GoTo errEnableShift

        Dim db As DAO.Database
        Dim prop As DAO.Property
        Const conPropNotFound = 3270
        
        Set db = OpenDatabase(CurrentProject.Path & "\" & [Forms]![frmMenu]![cmbDBName])

        db.Properties("AllowByPassKey") = True
        db.Properties("StartUpShowDBWindow") = True
        db.Properties("StartUpShowStatusBar") = True
        db.Properties("AllowFullMenus") = True
        'enable F11, ALT F11, etc. for short key
        db.Properties("AllowSpecialKeys") = True
        'allow Access Shortcut Menus. May be too severe
        db.Properties("AllowShortcutMenus") = True
        db.Properties("AllowToolbarChanges") = True
        db.Properties("AllowBreakIntoCode") = True
        
Exit Function

errEnableShift:
    'The first part of this error routine creates the "AllowByPassKey
    'property if it does not exist.
'    If Err = conPropNotFound Then
'        Set prop = db.CreateProperty("AllowByPassKey", _
'        dbBoolean, True)
'        db.Properties.Append prop
'        Resume Next
'        Else
'        MsgBox "Function 'apEnableShift' did not complete successfully."
'        Exit Function
'    End If

End Function


'if property is missing, make it!
Public Sub Check4MdbProp1(pDb, ByVal psProp As String)
   Dim prp As Property
   Dim strMDE As String

        With pDb
            On Error Resume Next
            'strMDE = .Properties("MDE")         'If this is an MDE or ACCDE database, disable bypass key
            If LCase(Right(pDb.Name, 4)) = ".mdb" Then strMDE = "T"
            If Err = 0 And strMDE = "T" Then
                .Properties(psProp) = 0
                
                If Err.Number = 3270 Then
                    On Error Resume Next
                            '    Set prp = .CreateProperty("AllowBypassKey", dbBoolean, False)
                            '    .Properties.Append prp
                            '    Set prp = .CreateProperty("AllowBreakIntoCode", dbBoolean, False)
                            '    .Properties.Append prp
                    Set prp = .CreateProperty(psProp, dbBoolean, False)
                    .Properties.Append prp
                    .Properties.Refresh
                End If
            End If
        End With
Set prp = Nothing
End Sub

Public Sub Check4MdbProps(pDb)
    Check4MdbProp1 pDb, "AllowByPassKey"
    Check4MdbProp1 pDb, "AllowBreakIntoCode"
End Sub

This post has been edited by ranman256: Jul 18 2019, 11:34 AM
Go to the top of the page
 
isladogs
post Jul 18 2019, 05:10 PM
Post#3


UtterAccess VIP
Posts: 1,549
Joined: 4-June 18
From: Somerset, UK


Although you could compact the current database using cod in earlier versions of Access, that feature was removed in A2010.
Over the years, I've tried various methods to get around that.
You can compact an external database and compact the existing db on close.
However I've not found any method of doing this on the current open dB using code.
If anyone knows a solution, I'd love to hear it


--------------------
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th August 2019 - 11:03 AM