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 IamaSherpa 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
 
I don't see a line that passes the recordset to the report.
Do you have a SetDataSource command in there somewhere? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
The datasource for the report is already set to the dataenvironment command from when I designed the report.
 
I was under the impression that you needed a SetDataSource command to pass a recordset. I haven't tried to do iterations so I am not sure I can be of much more help.
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Ok, maybe I should have a SetdataSource command.

What would the syntax be if my dataenvironment is called
Code:
DataEnv
and my recordset is called
Code:
rsInvoice
 
I don't think CR needs to know the data environment, since the report isn't connecting to it. The app is connecting and assembling the rs and that should be all that CR needs. I think you can use:

report.database.SetDataSource rs,3 Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top