Solved

Updating from Crystal Reports 8.5 to 10

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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 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…
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…

840 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