I'm trying to hide the "Ribbon" using VBA, and I can't produce the results I need. I know a variation of this topic has been posted several times, but I haven't seen a post that duplicates my issue.
The following code works when the database is in a DEBUG mode, but not when in production mode. This function is saved in a module and is called from main form's Load event (also tried Open and Current).
I use the following code the switch the application from a DEBUG mode to production mode.
I cannot find a way to set these database properties, and still allow myself to programmatically hide the Ribbon when not in a DEBUG mode.
Is there another solution?
The following code works when the database is in a DEBUG mode, but not when in production mode. This function is saved in a module and is called from main form's Load event (also tried Open and Current).
Code:
Public Function HideRibbon()
On Error Resume Next
If Not DEBUGMODE Then DoCmd.ShowToolbar "Ribbon", acToolbarNo
End Function
I use the following code the switch the application from a DEBUG mode to production mode.
Code:
Public Sub SetStartupProperties()
Dim OptionsAvailable As Boolean, msg As String
msg = "Set database securities?"
OptionsAvailable = IIf(MsgBox(msg, vbYesNo) = vbYes, False, True)
SetDbProp "AppTitle", IIf(OptionsAvailable, "DEBUG Applications Database", "Applications Database"), dbText
SetDbProp "StartUpShowDBWindow", OptionsAvailable, dbBoolean
SetDbProp "AllowFullMenus", OptionsAvailable, dbBoolean
SetDbProp "AllowBuiltInToolbars", OptionsAvailable, dbBoolean
SetDbProp "AllowSpecialKeys", OptionsAvailable, dbBoolean
SetDbProp "AllowBreakIntoCode", OptionsAvailable, dbBoolean
SetDbProp "AllowBypassKey", OptionsAvailable, dbBoolean
SetDbProp "DebugMode", OptionsAvailable, dbBoolean
Application.RefreshTitleBar
End Sub
Private Sub SetDbProp(sProperty As String, vData As Variant, vType As Variant)
On Error GoTo ErrorTrap
Dim db As Database, pProperty As DAO.Property
Set db = CurrentDb
db.Properties(sProperty) = vData
ExitSub:
Set db = Nothing
Exit Sub
ErrorTrap:
If Err.Number = 3270 Then
'create property if not found
Set pProperty = db.CreateProperty(sProperty, vType, vData)
db.Properties.Append pProperty
Resume Next
Else
'output all other errors
Debug.Print "ERROR " & Err.Number
Debug.Print "Property Set: " & sProperty
Resume ExitSub
End If
End Sub
I cannot find a way to set these database properties, and still allow myself to programmatically hide the Ribbon when not in a DEBUG mode.
Is there another solution?