MS Access Start up Properties

后端 未结 2 1996
面向向阳花
面向向阳花 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.

    0 讨论(0)
  • Don’t worry, If you have locked your database by using VBA codes. There is a simple way, just copy your database and paste somewhere in not trusted location.

    Access will show you a warning don’t click “enable”.

    Now you can close form, enable navigation panel and unhide objects.

    Once you change the code save file on trusted location.

    Hope you can understand me.

    0 讨论(0)
提交回复
热议问题