Use OLEDB to connect with mdb file : OLEDB « Access « VBA / Excel / Access / Word






Use OLEDB to connect with mdb file

 
'Microsoft ActiveX Data Objects Recordset 2.7 Library
Sub ConnectionExample1()
   Dim conn As ADODB.Connection
   Set conn = New ADODB.Connection

   With conn
     .Provider = "Microsoft.Jet.OLEDB.4.0;"
     .ConnectionString = "Data Source=" & _
        CurrentProject.Path & "\mydb.mdb"
   End With

   conn.Open
   MsgBox "Connection was opened"
   conn.Close
   Set conn = Nothing
   MsgBox "Connection was closed"
End Sub

 








Related examples in the same category

1.Opening a Database in Read/Write Mode
2.Opening a Database in Read-Only Mode
3.Opening a Password-Protected Database
4.Opening a Database Secured at the User Level