Sub Open_ReadOnly()
Dim conn As ADODB.Connection
Dim strDb As String
On Error GoTo ErrorHandler
strDb = CurrentProject.Path & "\mydb.mdb"
Set conn = New ADODB.Connection
With conn
.Provider = "Microsoft.Jet.OLEDB.4.0;"
.Mode = adModeRead
.ConnectionString = "Data Source=" & strDb
.Open
End With
Debug.Print "Database was opened for read-only access."
conn.Close
Set conn = Nothing
Debug.Print "Database was closed."
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description
End Sub
|