[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1081
  • Last Modified:

Crystal Reports XI Connection in Visual Basic

I am struggling to find a way to display my reports within Visual Basic 6 on a form. Reports are based on Microsoft SQL Server 2005 stored procedures.

I have the Crystal ActiveX Report Viewer Library 11 and the Crystal Reports ActiveX Runtime Library 11 added to my project. I have added the control to a form and declared the following:

Dim CRReport As New craxdrt.Report
Dim CRApp As New craxdrt.Application

I don't know where to go from here to display the report passing parameters.

Can anybody help.
0
chunnster
Asked:
chunnster
  • 2
1 Solution
 
ToFroCommented:
If you're new to this, try using the wizard.

1. Go to Project >> Components >> Designers, you should see an object named Crystal Reports 11, make sure it is checked.
2. Now go to Projects >> Add Crystal Reports 11, and the wizard should appear.
3. Choose the alternative that suits you best, and follow the wizard.
4. Study the code that was generated by the wizard.
0
 
ToFroCommented:
The Wizard creates a CrystalReport object. Modify the RecordSelectionFormula property of this object to supply parameters and limit results. Try doing a search for RecordSelectionFormula.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Function LoadReport(ReportName As String) As Boolean

  '<CSCM>
  '--------------------------------------------------------------------------------
  ' Project    :       PLB
  ' Procedure  :       LoadReport
  ' Description:       loads a report in the viewer
  ' Created by :       Project Administrator
  ' Machine    :       SCOTTS
  ' Date-Time  :       5/25/2005-09:39:04
  '
  ' Parameters :       ReportName (String): the full path, including name and extension, of the report
  '--------------------------------------------------------------------------------
  '</CSCM>

  Dim crxApp      As New CRAXDRT.Application
  Dim crxRpt      As CRAXDRT.Report
   
  On Error GoTo Err_LoadReport
  Screen.MousePointer = vbHourglass
           
  Set crxRpt = crxApp.OpenReport(ReportName)
   
  ctlCrystalViewer.ReportSource = crxRpt
  ctlCrystalViewer.ViewReport
  ctlCrystalViewer.DisplayToolbar = False
  ctlCrystalViewer.Refresh
 
Exit_LoadReport:
  On Error Resume Next
  Set crxApp = Nothing
  Set crxRpt = Nothing
  Screen.MousePointer = vbDefault
  Exit Function

Err_LoadReport:
  Select Case Err
  'case
  'case
    Case Else
      MsgBox Err & ":" & Error$, vbCritical, "frmReportViewer" & ": " & "LoadReport"
  End Select

  Resume Exit_LoadReport

End Function

ctlCrystalViewer is the CrystalActiveXReportViewer on the form ...
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now