Crystalkeen logo; we offer Crystal reports viewers and schedulers
Crystalkeen header image 3
Crystalkeen header image 5

Crystal Reports Tools: Improve Performance While Saving Time and Money




CR Schedulers
CR Viewers
DataBase Tools
Mail UFLs


About us

Contact Us

on Steroids

Crystal Reports:
Using the Report Designer Component (RDC) in Visual Basic

Integrating Crystal Reports into your Visual Basic project using the Crystal ActiveX control (OCX) requires very simple techniques and a small amount of code.

But when you add the OCX control to your project, you will get a warning that the OCX is obsolete, and that you should really use the RDC. We will now show you how to integrate the RDC into your Visual Basic program to view and process reports.

The first thing you need to do is to add the references and component to your project. You will need to include as a reference in your project: "Crystal Reports 8.5 ActiveX Designer Run Time Libraries". If you plan to view reports in a VB form, you will also need to add the "Crystal Report Viewer Control" as a component.

Because we reference our viewer from many different forms in our application, we declare public variables–use any method you find comfortable that is the equivalent to the following:

Public Appn as CRAXDRT.Application ‘Just needed to hold everything together

Public cReport as CRAXDRT.Report ‘Main object you will work with

Set Appn = CreateObject("CrystalRunTime.Application")

To load a report into the RDC you’ll need to set the cReport object to the report file name with

Set cReport = Appn.OpenReport(‘MyTest.rpt") ‘Or get your report name into the report somehow

Now you have the entire CR object model available to you. To send the report to your default printer, use:

cReport.PrintOut False

Displaying the report on a form requires the use of the Crystal Reports Viewer control. This control can be placed on a Visual Basic form and you can control it totally via code. The minimum you need to invoke the viewer is:

CRViewer.ReportSource = cReport


It’s also useful to include some code to resize the viewer on the form if the form is resized. One technique is to maximise the form with viewer control.

You also have the ability to have controls on that form directly control your report. One of the many features available to a programmer via the RDC is that you can interrogate and modify the record selection formula of the report.

cReport.RecordSelectionFormula = "{Customer.Region in [‘CA’, ‘OR’, ‘PA’, ‘TX’]"

And when you have finished don’t forget to release the objects with

Set cReport = Nothing

Set Appn=Nothing

Now, here's something to consider. You can create a simple viewer if you have the patience to do that. But, you won't have the features or functionality of our cView. "Rolling your own" is a bit like building your own car, these days.

With our viewer, you also save the time spent testing, troubleshooting, and supporting a home-grown solution.

This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects.


Except where an author's name is given at the start of the article, all of these articles were written by Mo Naughton or Bruce Ferguson and edited by Mark Lamendola. Mo is a Crystal Reports consultant, trainer, and developer for Chelsea Technologies, Inc. Bruce Ferguson is a Crystal Reports consultant, trainer, and developer for CrystalKiwi, Inc. Mark Lamendola is a writer and editor with over 15 years experience in professional and trade publications.


  • Questions? Please write to We do want your business.
  • Do you have your own tips for Crystal Reports administrators and designers? Write to and we'll post your tips with a link to your Website (or with some other attribution if you choose).
  • Crystal Reports is a subsidiary of Business Objects, which is owned by SAP.