Link Crystal Report to a VB6 ADO recordset, run report from vb6

I'd like to run some Crystal Reports directly from ADO recordsets in my VB6 application, but I don't know if it's possible, or the syntax to use. The data is in Oracle, and I use the recordsets in Grids on by VB forms. Thank you.
briankamAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mlmccConnect With a Mentor Commented:
Here is a link to help migrate from the OCX to the RDC
http://support.businessobjects.com/communityCS/TechnicalPapers/scr8-ocxtordc.pdf.asp

mlmcc
0
 
dkDeveloperCommented:
Hi briankam,

Have you tried something like this...

crxReport.Database.SetDataSource [ADO_RECORDSET_VAR]


Cheers!
dK
0
 
briankamAuthor Commented:
I tried:       Form1.CrystalReport1.Database.SetDataSource [rsReport_Query],
where rsReport_Query is defined with:
Public rsReport_Query As ADODB.Recordset
Set rsReport_Query = New recordset
rsReport_Query.Open "Select ... From ...",
but the CrystalReport1 control doesn't have a .Database property (to program errored to "Object doesn't support this property or method").
I'm trying to run the report with the command:
Form1.CrystalReport1.Action = 1
which displays Crystal in its own window, not a report viewer window (on a form). Thank you.

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
dkDeveloperCommented:
Hi dkDeveloper,

What version of CR are you using?

dK
0
 
briankamAuthor Commented:
Let me clarify:
In looking at older code, I see that I did just what you suggested, and it worked if I viewed the report in a Crystal Report Viewer Window on a VB6 form, using:
Dim Report As CRAXDRT.Report
Set Report = crystal.OpenReport("C:\appdir\...\Report_A.rpt")
Report.Database.SetDataSource rsReport_Query
CRViewer1.ReportSource = Report
CRViewer1.ViewReport

But I had no luck exporting data from in that scenario. So I'm trying to set the report's data source with the Crystal Report control (CrystalReport1) to the ADO recordset, and then call it with:
Me.CrystalReport1.ReportFileName = "C:\appdir\...\ReportA.rpt"
Me.CrystalReport1.Action = 1

but I don't see such a property on the Crystal Report Control.
Thanks again,
0
 
dkDeveloperCommented:
Hi briankam,

Stabbing in the dark again here but what about this...

Dim Report As CRAXDRT.Report
Set Report = crystal.OpenReport("C:\appdir\...\Report_A.rpt")
Report.Database.SetDataSource rsReport_Query
CRViewer1.ReportSource = Report
Me.CrystalReport1.Action = 1

Good Luck!
dK
0
 
briankamAuthor Commented:
Thanks dK,

I'm using CR v. 8.5 with VB6.

How should I define the 'crystal' you use in the 2nd line? When I initialized crystal with:

Public crystal As CRAXDRT.Application

I got an error on the set report = crystal.OpenReport("C:\...\Report_A.rpt"): Method or data member not found.

Thanks again,
0
 
mlmccCommented:
Are you using the RDC or the OCX?

The suggestions being made are for use with the RDC (CRAXDRT.DLL)

Your code seems to be for the OCX (crystl32.ocx)

I suggest you remove the OCX references and add the Crystal references and the Crystal RDC Viewer.

The OCX was dropped in CR9 and later versions so if you plan to upgrade in the future you will have to change your method.

mlmcc
0
 
briankamAuthor Commented:
Thanks mlmcc,

I need to look into the things you mention, as I'm not familiar yet with them.
0
 
AHMKC1Commented:
if you use Crystal Report control, create a report from CR then try

CrystalReport1.ReportFileName=Your report File Path
CrystalReport1.Action=1

if you use Crystal Report Viewer control i.e. OCX then

Design a report in your vb CR Designer and then try it
place a report veiwer control on form and write following code at load events

Dim Rpt As Report
Dim Rs As Recordset

Set Rs = New Recordset
Set Rpt = New ReportName
Rs.Open "SELECT * FROM TableName", Cnn, adOpenStatic, adLockOptimistic   ***** Where cnn is your Connection String
Rpt.Database.SetDataSource Rs, 3, 1

CRViewer1.ReportSource = Rpt
CRViewer1.ViewReport
CRViewer1.Zoom (100)
0
 
briankamAuthor Commented:
Thanks AHMKC1,

I have actually done both of the methods you mentioned. My final goal is to assign my ADO recordset as the source of the RDC report -- the first method you show (which will enable me to put all my filter logic in the VB code that generates the recordset). Thanks for any further help you can give.
0
 
AHMKC1Commented:
for filtering your data use Report Parameter

Create parameter in your report file on basis of your filtered field  (like  paramID)

Then on your form write follwing code

CrystalReport1.ReportFileName=Your report File Path
CrystalReport1.ParameterField(0)="ParamID;"& textID.Text & ";True"
CrystalReport1.Action=1

thanks
0
 
briankamAuthor Commented:
Thanks mlmcc, and I'm sorry I let the question lapse. What happened was that I upgraded to Crystal version 11, and I can set the ADO recordset as the datasource with: "      CrystalReport.Database.SetDataSource rsReport_Query", and can export while viewing in report viewer. So the solution was to upgrade.

All the comments were helpful though, to lead me there, but there wasn't a definitive solution.
0
 
mlmccCommented:
If a particular comment was helpful you can accept it with a B grade.  That is essentially what B means.  The comment led you to the solution.

mlmcc
0
 
mlmccCommented:
Glad i could help

mlmcc
0
All Courses

From novice to tech pro — start learning today.