Hi
The following is pretty clunky but will at least get you the data.
Make sure that your output file has sufficient sheets to house the data (I've used 65000 rows as the cut off point), you are on the first sheet and then run. You will have to adjust the selection criteria and the output criteria to suit.
This will select all the data from a database called c:\temp\test3.mdb, a table called access_table2. This table has 3 columns (expand to suit) that will be output starting in A2.
Sub bbb()
Set cn = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
cn.Open "provider=microsoft.jet.oledb.4.0;data source = c:\temp\test3.mdb"
cmd.activeconnection = cn
rs.Open "select * from access_table2", activeconnection:=cn
rs.movefirst
rowoff = 1
While Not rs.EOF
Range("A1").Offset(rowoff, 0).Value = rs(0)
Range("A1").Offset(rowoff, 1).Value = rs(1)
Range("A1").Offset(rowoff, 2).Value = rs(2)
i = i + 1
rowoff = rowoff + 1
rs.movenext
If i Mod 65000 = 0 Then
Sheets(ActiveSheet.Index + 1).Activate
rowoff = 1
End If
Wend
rs.Close
Set rs = Nothing
Set cmd = Nothing
cn.Close
Set cn = Nothing
End Sub
HTH
rylo
Bookmarks