Solved

Updating from Crystal Reports 8.5 to 10

Posted on 2006-11-30
2
461 Views
Last Modified: 2012-08-14
I have some legacy code which needs to be upgraded due to the changes made to crystal reports controls in the vb6 IDE
I was using crystal 8.5 which supplied a crystal32.ocx control and has worked fine.
We are upgrading our reports to crystal reports v10 and low and behold the crystal32.ocx  is no longer supported.

Firstly - do i have to use crystal designer? I would prefer not to embed the reports.
Can I dynamically load a report into an object and hand it to CrViewer? If so what is this object called?

the follow are the methods I use with the  crystal32.ocx control
1)  .DataFiles(0) = strBeerDataBase
2)  .ReportFileName = strReport_Path
3)  .SelectionFormula =  CriteriaCreator()
4)   .Action = Open
what are the equivelant in crystal reports v10 vb6 IDE objects
Cheers T
0
Comment
Question by:visualbasic
2 Comments
 
LVL 1

Accepted Solution

by:
weiroblpay earned 125 total points
ID: 18048928
Note:  I'm using Crystal 11, but I believe it's the same for 10
Here's some code I use to connect a report file (that I designed in Crystal and saved as a .rpt):

VB References:  
Crystal Reports Active X Designer
Crystal Reports Active X Designer Run Time Library  (craxdrt.dll)

Components:
Crystal Active X Report Viewer Library (crviewer.dll)

This code is in a class that works with reports

Dim crxTable As CRAXDRT.DatabaseTable
Dim m_crxApp As CRAXDRT.Application
Dim m_crxReport As CRAXDRT.Report
' m_strDSN holds the name of the system DSN that connects to the database - there may be a better way to connect the report, but this
' allows me to develpe the report using a development DB and run the report on a production system that may use a different DB name
' m_strDBName holds the name of the database - the Initial Catalog -
' m_strUID holds the userID needed to logon to the SQL database
' m_strPWD holds the password to log on to the database

' setup for SQL server
      Set m_crxApp = New CRAXDRT.Application
      ' log on to the server - if we don't do this here, the report can't be viewed
      m_crxApp.LogOnServer REPORT_DLL, m_strDSN, m_strDBName, m_strUID, m_strPWD
      ' open report object
      If Right$(ReportFile, 1) <> "\" Then
         strReportAndPath = m_strReportPath & "\" & ReportFile
      Else
         strReportAndPath = m_strReportPath & ReportFile
      End If
   
      Set m_crxReport = m_crxApp.OpenReport(strReportAndPath, 1)
      ' set each table to the correct DSN, DB, UID and PWD
      ' this is different for SQL databases - this allows us to use different
      ' settings than originally stored in the report
      For Each crxTable In m_crxReport.Database.Tables
         crxTable.SetLogOnInfo m_strDSN, m_strDBName, m_strUID, m_strPWD
      Next crxTable

' NOTE:  frmReports is a form with the crviewer.dll supplied control for previewing reports.
   Set m_frmRpt = New frmReports
   Load m_frmRpt
   m_frmRpt.Caption = "View Report"
   m_frmRpt.rptView.ReportSource = m_crxReport
   m_frmRpt.rptView.Visible = True
   m_frmRpt.rptView.ViewReport
   m_frmRpt.Show


For Access type databases, you could use this code instead:

'       open crystal app object to setup report
      Set m_crxApp = New CRAXDRT.Application
      ' open report object
      If Right$(ReportFile, 1) <> "\" Then
         strReportAndPath = m_strReportPath & "\" & ReportFile
      Else
         strReportAndPath = m_strReportPath & ReportFile
      End If
      Set m_crxReport = m_crxApp.OpenReport(strReportAndPath, 1)
      ' make sure each table in the report points to the correct database ....
      ' this will allow you to use any name for the database, instead of just the
      ' one that was saved with the report file - and allow us to store the reports
      ' anywhere we want instead of in the same folder with the database.
      For Each crxTable In m_crxReport.Database.Tables
         crxTable.Location = m_strDBName
      Next crxTable

' NOTE:  frmReports is a form with the crviewer.dll supplied control for previewing reports.
   Set m_frmRpt = New frmReports
   Load m_frmRpt
   m_frmRpt.Caption = "View Report"
   m_frmRpt.rptView.ReportSource = m_crxReport
   m_frmRpt.rptView.Visible = True
   m_frmRpt.rptView.ViewReport
   m_frmRpt.Show

Hope this helps.

Ron
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18063894
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now