Option Explicit Sub ボタン1_Click() Dim dbCon As ADODB.Connection Dim rst As ADODB.Recordset Dim sSQL As String Dim sFileInfo As String Dim sPWD As String Dim sCon As String ' DBのFULL Path ' 例)f:\temp\sample.mdb 又は f:\temp\sample.accdb sFileInfo = "[file path]" ' DB接続パスワード(ない場合はブランクに指定する) sPWD = "[password]" Set dbCon = New ADODB.Connection ' 以下の接続はAccess 2003以前バージョンののみ接続可能 ' dbCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ ' "Data Source = " & sFileInfo & ";" & _ ' "Jet OLEDB:Database Password=" & sPWD & ";" ' 以下の接続はAccess 2003以前バージョンも接続可能なのでこのコードを使うのが良い。 dbCon.ConnectionString = "Provider=<font color="red">Microsoft.ACE.OLEDB.12.0;</font>" & _ "Data Source= " & sFileInfo & ";" & _ "Jet OLEDB:Database Password=" & sPWD & ";" dbCon.Open sSQL = "Select * From tbl01" Set rst = New ADODB.Recordset rst.Open sSQL, dbCon, adOpenDynamic, adLockPessimistic If rst.EOF = False Then Do While rst.EOF = False Debug.Print rst("ID").Value rst.MoveNext Loop End If rst.Close Set rst = Nothing dbCon.Close Set dbCon = Nothing End Sub