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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing all records from a VB recordset, with no db set in the report 1

Status
Not open for further replies.

Trusts

Programmer
Feb 23, 2005
268
US
Hi,
I have a Crystal Report in which I removed all references to a database. The report has formula fields now, instead of database fields. From VB, I create a recordset and set the report formulas (the formula fields) to match the fields of the recordset.

The problem is that I only get the first record onto the report. The formula fields are in the detail section of the report. I have tried looping the recordset around the formula fields, like this:

For z = 1 To 8
Me.rptTraveler.Formulas(0) = "SerialNum='" & rs.Fields("Ser_Num") & "'"
Me.rptTraveler.Formulas(1) = "JobNum_1='" & rs.Fields("Job_Num1") & "'"
Me.rptTraveler.Formulas(2) = "Size_In='" & rs.Fields("Size_In") & "'"
Me.rptTraveler.Formulas(3) = "Manufac='" & rs.Fields("Manufac") & "'"
Me.rptTraveler.Formulas(4) = "VType='" & rs.Fields("V_Type") & "'"
rs.MoveNext
Next z


...But looping makes now difference - I still only have the first record appearing.

Is there a way to get around this. Do I need a different approach? I have specific reasons for not setting the database in the Crystal report itself. It is an old dbf file that is creating other problems in this application. I know that this technique works on another report that prints just one record. In this case they I need to print all the records returned from the recordset.

Thanks!

KB
 
There are a couple of different ways you could handle this, but the easiest would be to create a .ttx file that defines the fields that will be returned in the recordset. Then, create the report with the ttx as its datasource (I think it's under 'Field Definitions Only' in the Database Expert).

Once you have the fields defined, at runtime, you just hand the recordset off to the report like this using the RDC:

rptTraveler.DiscardSavedData
rptTraveler.SetDataSource rs

... and something like this if you're using the OCX:

rptTravelerSetTablePrivateData 0, 3, rs

Here are links to a couple of samples using active data w/CR:

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top