Access/VBA Library


Base function to protect your ACCDE application. Make sure this function is called at start up of your application.


Return value


Public Function ACCDE_init()
    Dim i
    ' Set development stage
    If Not IsACCDE() Then
        Call SetApplicationTitle(cVersion, "development")
        Exit Function
    End If
    ' Here : it's a ACCDE
    ' Check if the eye-cather exists. If it does, this function
    ' already has been executed
    If PropertyExists(cEyeCatcher) Then Exit Function
    ' Change the application title
    Call SetApplicationTitle(cVersion)
    ' Set all necessary properties
    ChangeProperty cEyeCatcher, dbBoolean, True
    ChangeProperty "AllowBypassKey", dbBoolean, False
    ChangeProperty "StartUpShowDBWindow", dbBoolean, False
    ChangeProperty "StartUpShowStatusBar", dbBoolean, False
    ChangeProperty "AllowShortCutMenus", dbBoolean, True
    ChangeProperty "AllowFullMenus", dbBoolean, False
    ChangeProperty "AllowBuiltInToolbars", dbBoolean, False
    ChangeProperty "AllowToolbarChanges", dbBoolean, False
    ChangeProperty "AllowSpecialKeys", dbBoolean, False
    ' Do we use a ribbon?
    If PropertyExists(cRibbonID) Then
        Dim ribbonName As String
        ' Get the name of the ribbon
        ribbonName = CurrentDb.Properties(cRibbonID)
        ' Only possible when the USysRibbon table is used
        If TableExists(cribbonBackstageTabel) Then
            Dim rs As Recordset
            ' Get the riboon XML and remove the standard Access-stuff
            Set rs = CurrentDb.OpenRecordset("SELECT RibbonXML " & _
                                             "FROM " & cribbonBackstageTabel & _
                                             " WHERE RibbonName = '" & ribbonName & "'")
            If Not rs.EOF Then
                rs!RibbonXML = ChangeRibbon(rs!RibbonXML)
            End If
            Set rs = Nothing
        End If
    End If
    ' Application settings are secure now. Notify the user and quit the application.
    ' At next start up, this code is not called again
    MsgBox "The application has been set up! Your application need to be restarted." & _
        vbCrLf & _
        "Click the OK button to close the application.", _
        vbInformation, GetApplicationTitle()
    Exit Function
    Resume ACCDE_init_exit
End Function

See also

  • SetApplicationTitle
  • ChangeProperty
  • PropertyExists
  • TableExists
  • ChangeRibbon