Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
cn.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\Administrator\My Documents\testdb.accdb")
strSQL = "SELECT * FROM table1;"
With rs
.ActiveConnection = cn
.Source = strSQL
.Open()
End With
rs.Open()
If rs.EOF = False Then
rs.MoveFirst()
End If
Do
MsgBox(rs.Fields("Field1"))
rs.MoveNext()
Loop Until rs.EOF = True
cn.Close()
cn = Nothing
rs = Nothing
|