Solved

Updating from Crystal Reports 8.5 to 10

Posted on 2006-11-30
2
463 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

919 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

16 Experts available now in Live!

Get 1:1 Help Now