[AccessD] Locked down database

Dan Waters df.waters at outlook.com
Mon Feb 2 19:53:10 CST 2015


Hi Doug,

A few years ago I wrote an Access mdb as a tool to clear the Shift Bypass
lockout.

Create a new ACCDB file, and put this code into a module.  Add a new macro
named AutoExec to run the function UnlockAccessFile().  You will need to
hold down the shift key to get into the code in this file.  I wrote this to
work with the MDB files I work with, but it might also work on an ACCDB.  

Save the Access file and name it Allow Bypass (works for me).

If you get an error send it to me and let me know what you were trying to
do.

Now open the Allow Bypass access file, locate the Access file you want to
get opened, and see if it works.  Also - it might be that the Allow Bypass
tool is actually working, but something else in your file is still locking
you out - but I don't know what would do that.

Good Luck!
Dan

-----------------------------------
Option Compare Database
Option Explicit

Private MappSource As Access.Application

Public Function UnlockAccessFile()
1     On Error GoTo EH

          '-- Note:  Run this application from this procedure.

          Dim stgSourceFilePath As String
          Dim stgPrompt As String
          
          '-- Select Access File
2         stgSourceFilePath = SelectFile
3         If stgSourceFilePath = "File Not Selected" Or stgSourceFilePath =
"" Then
4             MsgBox "Can't find file!", vbExclamation + vbOKOnly, "No File"
5             Exit Function
6         End If
7         DoEvents
          
          '-- Set Source MDB or ACCDB as the CurrentDatabase
8         Set MappSource = New Access.Application
9         MappSource.Visible = False
10        MappSource.OpenCurrentDatabase stgSourceFilePath
11        DoEvents
          
12        ChangeProperty "AllowBypassKey", dbBoolean, True  '-- Allow shift
key bypass
13        ChangeProperty "AllowSpecialKeys", dbBoolean, True  '-- Allow F11
key
14        ChangeProperty "AllowBreakIntoCode", dbBoolean, True
15        ChangeProperty "AllowFullMenus", dbBoolean, True
16        ChangeProperty "StartupShowDBWindow", dbBoolean, True
          
17        MappSource.CloseCurrentDatabase
18        Set MappSource = Nothing
          
19        MsgBox "Your file at " & stgSourceFilePath & " is now available!",
vbInformation + vbOKOnly, "File Now Available"
          
20        Exit Function
          
EH:
21        stgPrompt = "ERROR: SelectFile" & vbNewLine & vbNewLine _
              & "Line:            " & Erl & vbNewLine _
              & "Number:        " & Err.Number & vbNewLine _
              & "Description: " & Err.Description
22        MsgBox stgPrompt, vbExclamation + vbOKOnly
23        Stop
          
End Function

Private Function SelectFile() As String
1         On Error GoTo EH

          Dim fDialog As Office.FileDialog
          Dim stgPrompt As String
          Dim varFile As Variant

2         Set fDialog = FileDialog(msoFileDialogFilePicker)

3         With fDialog

4             .AllowMultiSelect = False
5             .InitialView = msoFileDialogViewList
6             .InitialFileName = CurrentProject.Path
7             .Title = "Select the Access file."

8             .Filters.Clear
9             .Filters.Add "Access Databases", "*.MDB"
10            .Filters.Add "Access Databases", "*.ACCDB"
              '.Filters.Add "Access Projects", "*.ADP"

              '-- Show the dialog box. If the .Show method returns True, the
_
               user picked at least one file. If the .Show method returns _
               False, the user clicked Cancel.
11            If .Show = True Then
12                For Each varFile In .SelectedItems
13                    SelectFile = varFile
14                Next varFile
15            Else
16                SelectFile = "File Not Selected"
17            End If

18        End With

19        Exit Function

EH:
20        stgPrompt = "ERROR: SelectFile" & vbNewLine & vbNewLine _
                      & "Line:            " & Erl & vbNewLine _
                      & "Number:        " & Err.Number & vbNewLine _
                      & "Description: " & Err.Description
21        MsgBox stgPrompt, vbExclamation + vbOKOnly
22    Stop

End Function

Public Function ChangeProperty(stgPropName As String, varPropType As
Variant, varPropValue As Variant) As Boolean
1     On Error GoTo EH

          Dim prp As DAO.Property
          Dim stgPrompt As String
          Dim dbs As DAO.Database
          
2         Set dbs = MappSource.DBEngine(0)(0)

3         dbs.Properties(stgPropName) = varPropValue

4         ChangeProperty = True

XH:
5         Exit Function

EH:
6         Select Case Err.Number

              Case 3270
                  '-- Add property if not already created
7                 Set prp = DBEngine(0)(0).CreateProperty(stgPropName,
varPropType, varPropValue)
8                 DBEngine(0)(0).Properties.Append prp
9                 Set prp = Nothing
10                Resume Next

11            Case Else
12                stgPrompt = "ERROR: SelectFile" & vbNewLine & vbNewLine _
                      & "Line:            " & Erl & vbNewLine _
                      & "Number:        " & Err.Number & vbNewLine _
                      & "Description: " & Err.Description
13                MsgBox stgPrompt, vbExclamation + vbOKOnly
14                Stop

15        End Select

End Function

---------------------------------



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Doug Steele
Sent: Monday, February 02, 2015 16:35 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] Locked down database

I've just been asked by an old client to 'rescue' a database so it can be
developed again.  This db was left in a locked down state of some kind by an
ex-employee of theirs. It wasn't an amicable parting :)

The database is in Access 2007 format.  It's not password protected, and it
is in .accdb format, not accde. The 'hold down the shift key to open'
option has been bypassed.  There is no 'design view' option when you right
click on a form, and of course all menus have been hidden.  I tried creating
an blank db and importing, but the forms list in the import window is greyed
out.

Does anyone have any suggestions?

Thanks,
Doug
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list