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

Crystal Reports ver. 8, VB6 and ADO

Status
Not open for further replies.

PJ2000

IS-IT--Management
May 30, 2000
10
0
0
US
I am using Crystal Reports ver. 8, Visual Basic 6, MS Access 97 and my data connections and etc are ADO.
I currently am using a direct connection to the database via: strConnection = "Driver={Microsoft Access Driver (*.mdb)};Dbq=Z:\database.MDB"

When I attempt to use the CRviewer code in the help file:
Dim CurrentReport As New dsrReport2275 'crystal rpt designer DD-2275 (data source is ADO)

Private Sub Form_Load()
Screen.MousePointer = vbHourglass
CurrentReport.Database.SetDataSource rsFundDocs 'recordset should be populated
rsFundDocs.MoveFirst 'move to first rec
CurrentReport.ReadRecords 'read it in to rpt
CRViewer1.EnableRefreshButton = True
CRViewer1.ReportSource = CurrentReport
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub

it dies out....

as I was perusing the forum I came across the following code
from a fowlerconsult:

Private Sub Form_Load()
Dim oApp As New CRPEAuto.Application
Dim oRpt As CRPEAuto.Report

Set oRpt = oApp.OpenReport("Z:\test.rpt", 1)

oRpt.Preview
End sub
which also fails (shows for a brief moment - then goes away)

After cruising the Seagate web site I came across the fact that changing the datasource at runtime can crash VB (Article ID: c2006592) if you are using VB6 with SP3. The fix is to install SP4 from Microsoft. I am now in the process of upgrading to SP4.

Ah... the question(s) finally.

1. What is/are the best connection method(s) for a database when implementing MS Access 97 and Crystal in a VB6 ADO application. (eg, Jet 4.0, OLE ODBC, etc)?

2. Is it better to create a crystal report with the external standalone editor (using a defined ado data source) and then implement it into you app or to build it inside the app with the designer? I would prefer to use the standalone as I can then hand a set of criteria to an individual and they can build the report w/o needing VB.

3. Once a report is completed can it then be encapsulated in a "self" executing file to send to an outside source that doesn't have access to my data - and do I have to hand them a subset of data (keeping in my mind, I have constructed this with ado data sources)?


 
>As I was perusing the forum I came across the
>following code from a fowlerconsulting:
>which also fails (shows for a brief moment - then goes away)

The following code creates a MDI form with the Smart Viewer in it, and does work. Minimize all your windows and you will find it ;-)

Regarding question #1 - Use the direct Access driver like you are to fetch an ADO recordset that you then pass to the reports.

Regarding question #2 - Actually the best way it to make parameterizes Access Queries, and then bind your report to the query, the report will prompt for the values and then pass them off to the Access Query. The Access Query with then filter out the reports for final report output. The concept here is to push as much record filtration in the DB sense that it what it does best. For Oracle and MS SQL users this means Stored Procedures.

Regarding question #3 - If they have parameters yes, if not just used saved data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top