Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a report before export from VB

Status
Not open for further replies.

SlothKiwi

Programmer
Jan 16, 2002
7
NZ
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top