Crystal Reports:
What is the
simplest way to run a Crystal Report
from Visual Basic?
There are several ways a Visual Basic developer can
integrate Crystal Reports into an application. The easiest way is to use the Crystal Reports ActiveX component.
Add this
component (Crystl32.OCX) to your project and put the object on a form somewhere. You will
need only one for your
entire project, as any form can reference and use the component.
The minimum code you need is:
crObject.ReportFileName = "c:\myfolder\myreport.rpt"
crObject.Action = 1
Action this from a menu item or command button click
event. Other menu items or buttons can call other reports just by using a different ReportFileName. There are many
other properties and methods of the object you can use.
The Report Designer Component (RDC) and Crystal
Report Viewer Control has appeared with recent version of Crystal Reports and is now the recommended method, but we
find the OCX is easier to use. And as it still works, we recommend staying with it.
Now, this brings up the question of why you'd be running
your Crystal Reports system from an application in the first place. While that's
certainly doable and maybe desirable for ease of use, it:
- Takes control of the reporting system away from the
administrator.
- Commoditizes the reporting system from a Business
Intelligence system to a secondary source of, usually, nearly raw data.
The control issue is of secondary importance to users; the effect on them is
simply a reduction in quality of what they're looking at. But it's of primary
importance to the report administrator, as it makes it harder for you to have
consistency, proper distribution, and timely updates. It also makes it harder
for you to prevent information silos. A better solution is a scheduler and
viewer approach, which we will discuss below.
You do not want to commoditize your reporting system or let it be just a way
of formatting raw data. If your reporting system isn't providing information
(not data) that answers critical business questions, then it's not really worth
the expense and fuss invested in it.
You can use a
Crystal Reports Scheduler to send reports to the distribution lists you
desire at the time you desire. This nearly solves the two problems mentioned
above.
To complete the solution, users need a way to view reports in their
native .rpt format. We sell
Crystal
Reports Viewers that allow them to do exactly that, even if they don't have
a Crystal Reports license. And they can refresh against live data.
Now, of course, this all depends on what you are doing with the report
itself. If it is just a fancy formatting of data then sending it to people can
actually be counterproductive. They will just copy the data into an Excel
spreadsheet and spend otherwise productive time playing with the data instead of
making business decisions.
So find out from users what business questions they need answered and design
your Crystal Reports to answer those questions. Use formulas to summarize,
total, average, extract, extrapolate, combine, aggregate, slice, and dice the
data however you have to so the report spares the user from having to wade
through data. An ideal report provides the concise business intelligence answers
the users are seeking, and nothing more.
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.
|