I am getting an error message on they FROM statement of the below code. Anyone see why?
Public Sub fill()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\Documents and Settings\speared\My Documents\db1.mdb"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM [Test]", cn, adOpenKeyset, adLockOptimistic, adCmdTable
With rs
.MoveLast
counter = .RecordCount
.MoveFirst
End With
ListBox1.ColumnCount = rs.Fields.Count
ListBox1.Column = rs.GetRows(counter)
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub
Public Sub fill()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\Documents and Settings\speared\My Documents\db1.mdb"
' open a recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM [Test]", cn, adOpenKeyset, adLockOptimistic, adCmdTable
With rs
.MoveLast
counter = .RecordCount
.MoveFirst
End With
ListBox1.ColumnCount = rs.Fields.Count
ListBox1.Column = rs.GetRows(counter)
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing
End Sub