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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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