Well I first thaought that a "read-only" permission on the back-end folder will not allow the "read-only" users to open the MDB file, as Access needs to create a LDB file in the folder when a MDB is open. But what happens if this back end database is opened "remotely" as a data source (and not a full "access file")? Access provides us with many methods to do so, such a linked tables (native access, ODBC connections, etc) & ADO connections.
Objectives:
The idea would be to check if there is a way to connect to the tables in the MDB file without "opening" it as an access file. One solution could be to create a link to a table located on the back-end database. Such a link can have different types, Access, ODBC, etc. I first thought it had to be ODBC, but native Access link seems to be ok here.
My steps:
- create main folder test\ with
subfolders test\data and test\code
- create 2 access database
test\data\data.mdb and
test\code\code.mdb
- open data.mdb, create a table called
Tbl_Object with 2 fields, add some
data
- put data.mdb and data\ folder in read-only mode (deny write to users at the folder level)
- open code.mdb
- add the following code to a VBA
module in code.mdb
Public Sub connectToData()
Dim rs As DAO.Recordset
''link Tbl_Object to current Access file
DoCmd.TransferDatabase acLink, "Microsoft Access", _
CurrentProject.Path & "\..\data\data.mdb", _
acTable, "Tbl_Object", "MyTable"
''open a recordset and browse through the records
Set rs = CurrentDb.OpenRecordset("MyTable")
rs.MoveFirst
Do While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
''display some important data in the immediate window
Debug.Print "Connection", CurrentDb.TableDefs("myTable").Connect
Debug.Print "Table", CurrentDb.TableDefs("myTable").SourceTableName
Debug.Print "Updatable", CurrentDb.TableDefs("myTable").Updatable
''drop the link
DoCmd.DeleteObject acTable, "myTable"
End Sub
Execute the code (run sub or call the sub in the immediate window)
Conclusion:
Check the results of the debugs. table can be viewed and browsed even if mdb file/folder are in read-only mode. No ldb lock file is created.
Read-only permissions set at the folder level will allow users to see the data without being able to update it, as long as a proper remote connection to the back-end file is created.