Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Add a Crystal Report (version 9) to a Visaul Basic 6 application.

Posted on 2003-02-24
Medium Priority
Last Modified: 2010-05-01
Hi all,

Please excuse my experience level, as I am new at this.  I'm trying to add a crystal report to a visual basic 6 application and have visual basic pass the SQL statement to the report.  Basically replace the SQL statement used in the database expert with what I specify.

Is this possible?

I'm using Crystal Reports Version 9, Visual Basic 6, and my data source is a mySQL server that has a system DSN set up.

Any help is appreciated.

Question by:bmelnick
  • 2
LVL 18

Accepted Solution

Sethi earned 400 total points
ID: 8008536
Yes it is very much possible. This is how you do it:
1. Design a report and save it as a .rpt file on your disk.
2. In Declaration Section:
'--- Report variables
    Dim rptApplication As CRAXDRT.Application
    Dim WithEvents rptReport As CRAXDRT.Report

3. Pass the new record source to the report and display report:
Set rptReport = rptApplication.OpenReport(App.Path & "\" & strReport & ".rpt")
strSQL="Select * from tablename"
rsGetData.Open strSQL, objConnection
        rptReport.Database.SetDataSource rsGetData
        rdcDisplay.ReportSource = rptReport

Just remember one thing - the data source being passed to the report should have the same field names as are there in the report.

Expert Comment

ID: 8901207
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 18

Expert Comment

ID: 8910928
Recommendation: Points to Sethi
LVL 49

Expert Comment

ID: 8972641
Moderator, my recommended disposition is:

    Accept Sethi's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question