MS Access Start up Properties

后端 未结 2 2005
面向向阳花
面向向阳花 2020-12-22 00:38

I was playing with some code online and tried the following in my project to disable default access ribbon

Sub DisableStartupProperties()
    ChangeProperty          


        
2条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 01:04

    From the above I understand that you have disabled the shift-key bypass. The best thing to do would be to use the copy you created before running this dangerous code :) If that is not possible, here are some ideas, first, you will need code to change the code in the locked database.

    Dim apAccess As New Access.Application
    Dim strCodeLine As String
    Dim lngLine As Long
    
    ''Where "c:\docs\test.mdb" is your database
    apAccess.OpenCurrentDatabase "c:\docs\test.mdb"
    
    ''Where module2 is the name of your module  
    With apAccess.VBE.ActiveVBProject.VBComponents("Module2").CodeModule
        s = "ChangeProperty ""AllowBypassKey"", dbBoolean, False"
    
        lngLine = 1
    
        ''EITHER
        ''This is useful if the code runs on start-up, if not, see OR
        If .Find(s, lngLine, 1, -1, -1) Then
            .ReplaceLine lngLine, Replace(s, "False", "True")
        End If
    
        ''OR
        ''Assuming that "Call DisableStartupProperties" is in a module, not a form
        If .Find("DisableStartupProperties", lngLine, 1, -1, -1) Then
            s = "Function RunMe()" & vbCrLf & s & vbCrLf & "End Function"
    
            .InsertLines lngLine - 1, s
        End If
    End With
    

    If you have chosen OR, you will now have to create a macro called Autoexec:

    RunCode : RunMe()
    

    And export that macro to your damaged database. Be very careful, back-up everything first.

提交回复
热议问题