Hello,
You need to tell your connection object where the workgroup information file is located as well:
Code:
Sub ConnectToSecuredMDB()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String
On Error GoTo Err_Handler
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source") = "C:\SecuredDatabase.mdb"
.Properties("Jet OLEDB:System Database") = "C:\WorkgroupInformationFile.mdw"
.Properties("Mode") = adModeShareDenyNone
.Properties("User ID") = "John Doe"
.Properties("Password") = "John"
End With
cnn.Open
strSQL = "SELECT * FROM tblRecords"
Set rst = New ADODB.Recordset
rst.Open strSQL, cnn, adOpenForwardOnly, adLockReadOnly, adCmdText
Debug.Print rst.GetString(adClipString, , ";")
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Exit Sub
Err_Handler:
If Not rst Is Nothing Then
If rst.State = adStateOpen Then rst.Close
End If
Set rst = Nothing
If Not cnn Is Nothing Then
If cnn.State = adStateOpen Then cnn.Close
End If
Set cnn = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error"
End If
End Sub
HTH,
Bob