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

recordset on subreport vb6

Status
Not open for further replies.

prettitoni

Programmer
Apr 22, 2004
74
US
I hope someone here can help me. I'm trying to call up a CR8.5 report with 2 subreports thru VB6 and can't get it to work. The primary report is filtering the correct records, but the subreports aren't. The queries are returning the correct records (I checked it in Access), but it's not reflecting on the report. This is what I have after I've set up my connections and queries....

For Each crxTable In crxReport.Database.Tables
crxTable.Location = App.Path & "\theDBname.mdb"
Next

crxReport.DiscardSavedData
crxReport.Database.SetDataSource rs1

Set crSections = crxReport.Sections

'Go through each section in the main report...
For Each crSection In crSections
Set crObjects = crSection.ReportObjects
For Each newObject In crObjects
If newObject.Kind = crSubreportObject Then
Set crxSubObj = newObject
Set crxSub = crxSubObj.OpenSubreport

crxSub.DiscardSavedData
If crxSubObj.SubreportName = "FReport.rpt" Then crxSub.Database.SetDataSource rs2
If crxSubObj.SubreportName = "F2Report.rpt" Then crxSub.Database.SetDataSource rs3
End If
Next newObject
Next crSection

CRViewer1.ReportSource = crxReport
CRViewer1.ViewReport
 
A couple of questions...

1) Have you verified that rs2 and rs3 contain records?

2) Are you linking the subreports to the main report, or are they standalone subreports?

The code is fine, so the problem probably lies in the recordsets, or in the report(s).

Add a couple of Debug statements to verify that the DecriptiveName (sic) is "Active Data (ADO)":

[tt]Debug.Print crxReport.Database.Tables(1).DecriptiveName[/tt]
and
[tt]Debug.Print crxSub.Database.Tables(1).DecriptiveName[/tt]

-dave
 
1) Yes and both do
2) They are standalone reports called into Crystal Reports with Insert->Subreports....is that okay?
3) uh oh...when I put the debug lines in, it returned: Active Data (Field Definitions Only)
Microsoft DAO Database DLL
for the main and subreport respectively...guess I have to fix the subreport?
 
Um...for the subreport (I'm trying to get one working first), I am setting up the database driver the exact same way as the primary, so why is one showing Active Data (Field Definitions Only) and the other Microsoft DAO Database DLL?
 
All three should be using Active Data.

Open up the subreports, go to Database > Convert Database Driver, and pick "Pdsmon.dll". Then you'll get prompted for your data source. It's up to you whether you want to use Data Definition (TTX files), or pick ADO and OLE DB, then set up the connection string, and type in your SQL.

-dave
 
I did that....but I didn't type in the SQL..that gets filled in thru my VB code. But, I chose Pdsmon.dll->ADO & OLE DB for all subreports and it still tells me Microsoft DAO Database DLL
 
If you're not supplying the SQL, or a ttx file, then the report has no idea what the fields are supposed to be, and that's also why it keeps reverting to pdbdao.dll.

Copy the SQL you're using to fill your recordsets, and paste that in when it prompts you.

-dave
 
I recreated my subreports and chose More Data Sources -> Active Data from the list instead of Database Files and it is working now. With the Debug.Print crxReport.Database.Tables(1).DecriptiveName
line, I now get ADO for all repors. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top