I have a crystal report that I am trying to export to multiple Paginated Text files, and I want to filter the recordset for the report before each export. However, for some reason when the report is exported, it doesn't appear to be using the filtered recordset, instead it uses the recordset as it stands before I apply any filters. My code is as follows (Please note that the Crystalreport gets it data from a recordset in my dataenvironment called rsInvoice):
Code:
Private Sub cmdExport_Click()
Dim adoCN As New ADODB.Connection
Dim adoRS As New ADODB.Recordset
strsql = "SELECT * FROM qryInvoice"
adoRS.Open strsql, adoCN
Do While Not adoRS.EOF
DataEnv.rsInvoice.Open
DataEnv.rsInvoice.Filter = "OrderID = " & adoRS.Fields("OrderID")
rptInvoice.ExportOptions.DestinationType = crEDTDiskFile
rptInvoice.ExportOptions.FormatType = crEftpaginatedText
rptInvoice.ExportOptions.NumberOfLinesPerPage = 60
rptInvoice.ExportOptions.DiskFileName = "d:\" & adoRs.Fields("OrderID") & ".prn"
rptInvoice.Export False
adoRS.MoveNext
Wend
End Sub