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!

Passing ADO rs to a report which has more than one table...

Status
Not open for further replies.

rizvir

Programmer
Aug 7, 2000
12
TH
I am using CR8 and VB6 to pass an ADO recordset to a report created using RDC. If my report has only one table then there is no problem and the following code works perfectly:

.....
.....
myrs.open "Select * from MyTable WHERE Myfield='abc'", mycon
set crDbtables = crDatabase.Tables
set crDbtable = crDbtables.Item(1)
crDbtables.SetDataSource myrs, 3
CRViewer1.ViewReport
.....

But if I add another table to the same report (and define or not define a relationship - in both cases) then the same code gives two errors - Unable to access first record! and then SQL Server Error.
I am using Active Data Driver P2SMON.DLL. I am using a Dynamic Client-Side cursor as advised in a document on the Crystal Decisions web-site.

TIA for any help or suggestions
Rizwan
 
Did you ever receive an answer to this question? I am experiencing a similar problem.

I loop through all the tables, and SetDataSource to the appropriate recordset. When the report previews, the fields in the page header are blank. Opening the same report and database within CR 8 works fine. I am working with both MS Access 2000 and SQL Server 2000 (it works the same both ways).
 
Well, I did not receive any reply but then played around a bit to find out that the only probable solution is to make a reference to each table used in report. This way you can change the recordset of any table you wish. I experimented only with CR8 and it worked fine, but, of course if you have a cross-table report involving 15-20 tables, then this solution neither is idealistic not efficient.
 
You can only pass a recorset to a report that uses one "virtual" table. So if the report has multiple tables, it has to be recreated against the active data driver or a TTX file, so that is simply expects a single table, not multple tables. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top