Solved Hide ribbon code not working (1 Viewer)

Mina Garas Daniel

Registered User.
Local time
Today, 03:39
Joined
Jul 21, 2017
Messages
66
Hello everyone
I have a problem and try many times to solve it but i failed
i build StartUp form to disable startup properties

in screen splash on load event

i wrote below code

Code:
Private Sub Form_Load ()
    ' Go Modal to Lock Navigation Pane
       Me.Form.Modal = True
       ' Hide Navigation Pane
       DoCmd.NavigateTo "acNavigationCategoryObjectType"
       DoCmd.RunCommand acCmdWindowHide
       ' Hide Ribbon
       DoCmd.ShowToolbar "Ribbon", acToolbarNo
       ' Lock Navjgation Pane
       DoCmd.LockNavigationPane (True)
call 
End Sub

and use following module its name modStartUpProps to disable startup properties

Code:
Option Compare Database
Option Explicit


Function StartUpProps(strPropName As String, Optional varPropValue As Variant, _
          Optional ddlRequired As Boolean) As Variant
    
' From Securing Your Microsoft Access Databases
' Modified from MS Access 97 examples by Garry Robinson.
' This function requires a reference to DAO library
    
' This function will both return and set the value of startup properties
' in your database.  It can also be used for other database properties
' with some slight modification.

Dim dbs As DAO.Database, prp As DAO.Property, varPropType As Variant
Const conPropNotFoundError = 3270

If IsMissing(ddlRequired) Then
  ddlRequired = False
End If
    
' Because this code is specific to the startup properties, we assume that the
' data type of the property is Boolean unless stated otherwise

varPropType = dbBoolean
Select Case strPropName
  Case "StartupForm", "AppIcon"
    varPropType = dbText
End Select
    
Set dbs = CurrentDb

' This function will either set the value of the property or try to
' return it.  It knows which mode it is in by the existence of the
' property value in the procedure that called the function.

If Not IsMissing(varPropValue) Then

' As we change the value of the startup property, we will first try to
' assign that value.  If the property does not exist, it will be
' added to the database object using the error handling code.
 
  On Error GoTo AddProps_Err
  dbs.Properties(strPropName) = varPropValue
  StartUpProps = True
Else

' If we find out the value of the startup property, we first see if
' that value exists.  If the property does not exist, we will return a null string.
 
  On Error GoTo NotFound_Err
  StartUpProps = dbs.Properties(strPropName)
End If

StartupProps_End:
  On Error Resume Next
  Set dbs = Nothing
  Set prp = Nothing
  Exit Function

AddProps_Err:
 
  If Err = conPropNotFoundError Then
    'Property not found when adding a property value
    Set prp = dbs.CreateProperty(strPropName, varPropType, _
               varPropValue, ddlRequired)
    dbs.Properties.Append prp
    Resume Next
  Else
    'Unknown error.
    StartUpProps = False
    Resume StartupProps_End
  End If

NotFound_Err:
    If Err = conPropNotFoundError Then
      'Property not found when returning a property value
      StartUpProps = Null
      Resume Next
    Else
      'Unknown error.
      StartUpProps = False
      Resume StartupProps_End
    End If

End Function

Sub resetStartProps()

'Reset all the startup properties by deleting them
'Generally this is only advisable if you then intend to recreate
'the Starup properties using the ddlRequired variable

  DeleteStartupProps "StartupShowDBWindow"
  DeleteStartupProps "StartupShowStatusBar"
  DeleteStartupProps "StartupMenuBar"
  DeleteStartupProps "StartupShortcutMenuBar"
  DeleteStartupProps "AllowBuiltinToolbars"
  DeleteStartupProps "AllowFullMenus"
  DeleteStartupProps "AllowShortcutMenus"
  DeleteStartupProps "AllowToolbarChanges"
  DeleteStartupProps "AllowBreakIntoCode"
  DeleteStartupProps "AllowSpecialKeys"
  DeleteStartupProps "AllowBypassKey"

  StartUpProps "StartupShowDBWindow", False, True
  StartUpProps "StartupShowStatusBar", False, True
  StartUpProps "StartupMenuBar", False, True
  StartUpProps "StartupShortcutMenuBar", False, True
  StartUpProps "AllowBuiltinToolbars", False, True
  StartUpProps "AllowFullMenus", False, True
  StartUpProps "AllowShortcutMenus", False, True
  StartUpProps "AllowToolbarChanges", False, True
  StartUpProps "AllowBreakIntoCode", False, True
  StartUpProps "AllowSpecialKeys", False, True
  StartUpProps "AllowBypassKey", False, True
 
End Sub

Function DeleteStartupProps(strPropName As String) As Boolean

'Function requires a reference to DAO library

Dim dbs As DAO.Database, prp As DAO.Property
Const conPropNotFoundError = 3270
    
DeleteStartupProps = False
    
On Error GoTo deleteStartupProps_Err
CurrentDb.Properties.Delete (strPropName)
DeleteStartupProps = True

deleteStartupProps_End:
  On Error Resume Next
  Set dbs = Nothing
  Set prp = Nothing
  Exit Function

deleteStartupProps_Err:
  If Err = conPropNotFoundError Then  ' Property not found.
    DeleteStartupProps = False
    Resume Next
  Else
    'Unknown error.
    Resume deleteStartupProps_End
  End If

End Function

the problem i face every thing working good except ribbon still appear not hidden
Can anyone help
Thanks
 
Have a look at my example app which includes code to hide/show the ribbon and much more as well
 
Have a look at my example app which includes code to hide/show the ribbon and much more as well
Thanks you very much for your response
I read codes carefully and I have a question specialy my knowledge in VBA very simple not like u

Most of codes wrote for command buttons
How can I convert codes to use it in splash form onload event
To disable startup properties like hide navigation pane,ribbon, menus ..etc

Thanks
 
As you want to disable several startup properties, I suggest you study my article:

This includes an example database and all code you need to apply a range of security features to your Access files
 
As you want to disable several startup properties, I suggest you study my article:

This includes an example database and all code you need to apply a range of security features to your Access files
Thank you very much again for your response and great effort that clearly appear in tht link
really codes very useful, i literally follow your codes for
Hide Nav pane
Hide ribbon
Bybass shift key
until here every thing is ok when i test the db every thing working good

but i don't know why ribbon appear again when i use ModifyStartUpProps in Startup form onload event
i attached my db i will be thankful if you can help me
Thanks
 

Attachments

Hello
I took your database for a test.
Hiding the ribbon is correct in edit mode but not when opening in live mode.
After several tries and checks, I couldn't find the problem.
So I recreated a new database with your forms. I simply used the 'DoCmd.ShowToolbar "Ribbon", acToolbarNo' method and set the active database options.
It works correctly.
I am attaching the working database.
 

Attachments

Hello
I took your database for a test.
Hiding the ribbon is correct in edit mode but not when opening in live mode.
After several tries and checks, I couldn't find the problem.
So I recreated a new database with your forms. I simply used the 'DoCmd.ShowToolbar "Ribbon", acToolbarNo' method and set the active database options.
It works correctly.
I am attaching the working database.
Thanks for your response and effort, that what i say when i need to hide nave pane and ribbon its working but i need also disable other properties like special keys, menus, right click ... etc so i use @isladogs modules but when i use ModifyStartUpProps in onload event for splash form ribbon come back again this is the real problem i face thanks
 
Dears
I can't find a solution
i reinstall office it self, when i use codes for hide ribbon and nave pane
but when i use @isladogs method when i put in onload event for splash form to reset startup properties ribbon appear again

i need to use this module to disable special keys and menus
any help
Thanks
 
i do something that fix the problem partially i edit the code to be like following
Code:
Sub ModifyStartUpProps()

'Call this from your startup form

On Error GoTo Err_Handler

    'Delete existing start up properties
    DeleteStartupProps "AllowFullMenus"
    'DeleteStartupProps "StartUpShowStatusBar"
    'DeleteStartupProps "AllowBuiltInToolbars"
    DeleteStartupProps "AllowShortcutMenus"
    'DeleteStartupProps "AllowToolbarChanges"
    DeleteStartupProps "AllowSpecialKeys"
    DeleteStartupProps "StartUpShowDBWindow"
    'DeleteStartupProps "AllowBypassKey"

    'By default, set all start up properties to False
    'StartUpProps "AllowBypassKey", False, True
    StartUpProps "AllowFullMenus", False, True
    'StartUpProps "StartUpShowStatusBar", False, True
    'StartUpProps "AllowBuiltInToolbars", False, True
    StartUpProps "AllowShortcutMenus", False, True
    'StartUpProps "AllowToolbarChanges", False, True
    StartUpProps "AllowSpecialKeys", False, True
    StartUpProps "StartUpShowDBWindow", False, True
    
Exit_Handler:
    Exit Sub
    
Err_Handler:
    MsgBox "Error " & Err.Number & " in ModifyStartUpProps procedure : " & Err.Description, vbOKOnly + vbCritical
    Resume Exit_Handler

End Sub

i disable delete and create many properties
when i do that ribbon not appear again
but why the full code not working with me
any help
thanks
 
I had just started looking at it yesterday but stopped when I saw a solution had been offered.
I'll try to find time to look at it later this evening UK time if nobody else steps in first.

You can use ACCDE or ACCDR in a multi-user environment providing each user has their own copy of the FE on their local hard drive
ACCDR will lock down the database significantly BUT it can easily be renamed to ACCDE/ACCDB and that security is removed.
Never rely on ACCDR on its own.
 
thanks for your response i have a question is accdr working for multiuser environment or must using accde
As mentioned, it's still the same file even if you changed the file extension. So, it will still work in a multi-user environment.
 
Fixed version attached.
I also couldn't see anything obviously wrong but the HideRibbon code just wasn't working
I imported the entire modRibbon code from my own app - you need this so you can show/minimize the ribbon when required.
It still didn't work ...

So I imported everything into a new blank database and its now fine.
My conclusion is that one of the objects was corrupted

You may have to open the database twice before the hide ribbon code takes effect
 

Attachments

in my access databases when i want to hide the ribbon, I use the following and so far it has worked a treat

Code:
Private Sub Form_Load()


'    hides ribbon so unable to click on privacy settings
    DoCmd.ShowToolbar "Ribbon", acToolbarNo
    
End Sub
 
Yes that is the same code as used in the OP’s app. See post #1.
Normally it works perfectly. However in this case it didn’t due presumably to corruption
 
Yes that is the same code as used in the OP’s app. See post #1.
Normally it works perfectly. However in this case it didn’t due presumably to corruption
Thanks so much for your care,
i try fixed version by you its working fine if i not activate ModifyStartUpProps sub in splash screen onload event
i attched my copy after activate this sub and unfortunately ribbon appear again
Please check attached file
thanks
 

Attachments

Sorry - I forgot to say that I'd deliberately disabled the ModifyStartUpProps code because parts of it conflict with the HideRibbon code.
As it says in my article:
As this procedure duplicates many of the other methods described above, you may need to remove any repeated code

In fact, many of the commands are redundant if you hide the ribbon. For example:
  • you cannot have short or full menus with no ribbon nor can toolbar changes occur as there is no toolbar
  • you don't need to set ShowDBWindow false as you are hiding the nav pane
If you really want to use code to disable some startup props, enable them one at a time to test which properties trigger the ribbon to show
Remember to restart Access twice after each change to ensure the change has been implemented

Alternatively, have a minimal ribbon with an empty File menu and apply the ModifyStartUpProps code
Hope that helps
 
Sorry - I forgot to say that I'd deliberately disabled the ModifyStartUpProps code because parts of it conflict with the HideRibbon code.
As it says in my article:


In fact, many of the commands are redundant if you hide the ribbon. For example:
  • you cannot have short or full menus with no ribbon nor can toolbar changes occur as there is no toolbar
  • you don't need to set ShowDBWindow false as you are hiding the nav pane
If you really want to use code to disable some startup props, enable them one at a time to test which properties trigger the ribbon to show
Remember to restart Access twice after each change to ensure the change has been implemented

Alternatively, have a minimal ribbon with an empty File menu and apply the ModifyStartUpProps code
Hope that helps
Thanks alot for your support I just want to know if my approach right or not based on your comment it's right thanks alot again
 

Users who are viewing this thread

Back
Top Bottom