J
JCP
I created a recordset and now I need to use recordset filter to export data
into excel.
I use the CopyFromRecordset method to export data into excel
When I use this method using the recordset filter, it ignores the filter and
CopyFromRecordset export to all records to excel.
There is an away to export data to excel from a ado.recordset filter?
Dim cnn as ADODB.connection
Dim rs as ADODB.recordset
Dim rs1 as ADODB.recordset
' Code to open a specifive excel file ...
Set cnn= CurrentProject.Connection
Set rs= New ADODB.recordset
rs.Open strSQL, cnn 'This recordset has 62 rows;
rs.filter="Source='Bagre'" 'This recordset has 7 records
xlBook.Sheets(1).Range("D10").CopyFromRecordset rs
'The line above copy all data from the recordset, I mean, copy into excel
62 records and not 7. It ignore the filter
also I tried:
Dim cnn as ADODB.connection
Dim rs as ADODB.recordset
Dim rs1 as ADODB.recordset
‘Code to open a specifive excel file ...
Set cnn= CurrentProject.Connection
Set rs= New ADODB.recordset
rs.Open strSQL, cnn 'This recordset has 62 rows;
rs.filter="Source='Bagre'" 'This recordset has 7 records
set rs1=rs
xlBook.Sheets(1).Range("D10").CopyFromRecordset rs1
'The results is the same, export all records into excel.
How can I export only the records filtered?
Thanks for any suggestions.
jcp
into excel.
I use the CopyFromRecordset method to export data into excel
When I use this method using the recordset filter, it ignores the filter and
CopyFromRecordset export to all records to excel.
There is an away to export data to excel from a ado.recordset filter?
Dim cnn as ADODB.connection
Dim rs as ADODB.recordset
Dim rs1 as ADODB.recordset
' Code to open a specifive excel file ...
Set cnn= CurrentProject.Connection
Set rs= New ADODB.recordset
rs.Open strSQL, cnn 'This recordset has 62 rows;
rs.filter="Source='Bagre'" 'This recordset has 7 records
xlBook.Sheets(1).Range("D10").CopyFromRecordset rs
'The line above copy all data from the recordset, I mean, copy into excel
62 records and not 7. It ignore the filter
also I tried:
Dim cnn as ADODB.connection
Dim rs as ADODB.recordset
Dim rs1 as ADODB.recordset
‘Code to open a specifive excel file ...
Set cnn= CurrentProject.Connection
Set rs= New ADODB.recordset
rs.Open strSQL, cnn 'This recordset has 62 rows;
rs.filter="Source='Bagre'" 'This recordset has 7 records
set rs1=rs
xlBook.Sheets(1).Range("D10").CopyFromRecordset rs1
'The results is the same, export all records into excel.
How can I export only the records filtered?
Thanks for any suggestions.
jcp