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 recordset with vb6 to CR 9?? 1

Status
Not open for further replies.

BiggerBrother

Technical User
Sep 9, 2003
702
GB
I've used the following code to pass the ADO recordset to the report, but, at the moment, it fowls on the first line of the form load code:

Dim CrAppl As CRAXDRT.application
Dim CrRep As CRAXDRT.Report
Dim AdoRs As ADODB.Recordset

Private Sub Form_Load()
Set CrRep = CrAppl.OpenReport("C:\temp\adors.rpt") 'error here!
CrRep.Database.Tables(1).SetDataSource AdoRs, 3
CrViewer1.ReportSource = CrRep
CrViewer1.ViewReport
End Sub

The returned error is "object or with block not set".

Why would this be? I've tried a couple of reports, and various sql statements for the recordset with no luck. Obviously, I'm missing something, it's just what?

Many thanks

BB
 
Try:

Private Sub Form_Load()
Set CrAppl = New CRAXDRT.Application
Set CrRep = CrAppl.OpenReport("C:\temp\adors.rpt") 'error here!
...
...

-dave
 
I'm still missing something! I left before easter thinking all was well, but on my return, found things weren't quite as hoped.

I'm new to using CR with VB, so please bare with me.

What settings do I use for my database connection when connecting to a recordset at run-time? The report will always show the same type of data, but not necessarily from the same source.

Many thanks

BB
 
Probably the 'best' way to design a report to not be dependent on a particular data source is to use the Active Data driver. How you set it up depends on your version of Crystal.

If you have CR 8.5, when choosing your data source, go to More Data Sources > Active Data. You can choose ADO or 'Field Definitions'. If you choose ADO, it'll prompt you for connection information, then eventually allow you to type in a SQL statement that defines your recordset. If you choose 'Field Definitions (ttx)', you'll be prompted to build your field list manually (field name, data type, sample data).

Once the report is set to use the Active Data driver (p2smon.dll in CR 8.5), you should be able to pass a recordset to the report at runtime without any problems, as long as the field names and data types of your recordset match the fields expected by the report.

-dave
 
Unfortunately, I've got CR 9, and the active data option is not available in the more data sources list. Did things change between 8.5 and 9? Or there something else I need to make this work?

Many thanks

BB
 
For CR 9, from the Database Expert, chosse either 'OLE DB (ADO)' or 'Field Definitions Only'. Either one should still accept a recordset at runtime.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top