• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1086
  • 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.
  • 2
1 Solution
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.
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.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Function LoadReport(ReportName As String) As Boolean

  ' 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

  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.DisplayToolbar = False
  On Error Resume Next
  Set crxApp = Nothing
  Set crxRpt = Nothing
  Screen.MousePointer = vbDefault
  Exit Function

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

  Resume Exit_LoadReport

End Function

ctlCrystalViewer is the CrystalActiveXReportViewer on the form ...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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