Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nooble question VB6 & crystal reports

Status
Not open for further replies.

anthonyabf

Programmer
Aug 30, 2004
3
US
Howdy,

I am a new user to VB 6 and CR 10. I have my VB project and my CR report named MyDiveLog. I just don't know how to integrate the two. I want to click a button in the application and view/print the report.
I bought the Crystal Reports Complete Reference today. Seems it has chapters and chapters on how to do the fancy stuff but doesn't tell me how to simply view the report MyDiveLog.rpt. This is the code I tried, but I get a "compile error - user defined type not defined"



Private Sub Form_Load()

Dim myReport As CrystalReport1
Set myReport = New CrystalReport1
CRViewer.ReportSource = myReport
CRViewer.ViewReport
End Sub



Please help!
 
Are you trying to open a report from a file location (like C:\Reports\MyReport.rpt), or are did you design the report within the VB IDE?

If from a file location, have a look at this thread: thread766-789962. Make sure you've added the Crystal Reports Viewer Control component, and a reference to the Crystal Reports 10 ActiveX Designer Run Time Library (craxdrt.dll).

... And you have a Developer version of Crystal, right?

-dave
 
Dave,

I have CR version 10.0.0.533 Professional. Man, please don't tell me I cant use it inside VB 6.

The report is located at
C:\Program Files\ScubaNotes Dive Log\MyDiveLog.rpt
 
Sorry, but I think trying to use it in an application without a valid Developer Edition license is frowned upon.

If upgrading to CR 10 Developer is out of the question, you might want to check out some other Report Viewers/Managers out there, some of which can run reports from a command line, which you'd be able to invoke from VB:

-dave
 
Ummmm, I think it works. I haven't actually tried it on another PC, but it seems to work on this one. Thanks for all the help. The sample code and other questions got me on the right track.

Upgrading is out of the question. I'm just doing this for a hobby, not professionally or to make money.

I'll check the link and see. I tried SctiveReports 2.0 but I didn't know how to make all the required DLL files on the users PC, so it wouldn't show the report.

Anthony
 
In VB6 I'd recommend this approach.

1. Add a reference to your VB project. Look for Crystal Reports ActiveX Designer Run Time Library. This should refer to the file CRAXDRT.DLL

2. Add a reference to the Crystal ActiveX Report Viewer library 10.0 (CRViewer.dll)

3. Create a form with a CR Viewer object on it. Resize as needed.

4. The minimum code you need now is...
Dim Appn As CRAXDRT.Application
Dim cRpt As CRAXDRT.Report

Set Appn = New CRAXDRT.Application
Set cRpt = Appn.OpenReport("c:\reports\this.rpt")
CRView.ReportSource = cRpt
CRView.ViewReport

There are a bunch of other properites and methods you can invoke prior to viewing the report. For example login to the database, set parameter values, interrogate and change the record selection formula. But the above is a minimum value.

Good luck

Editor and Publisher of Crystal Clear
 
HI Everyone,
I need some help with a crystal reports problem. We've just upgraded to 9 from 8.5 and now several of my forms won't view correctly. On every form I've got with check boxes, there are strange characters preceding them. I've gone over the sql too many times and can't find the problem. Here's an example:

SELECT
t.SFIRSTNAME + ' ' + t.SLASTNAME + ' ' + LTRIM(RTRIM(ISNULL(r.rm1first, '')) + ' ') + RTRIM(ISNULL(r.rm1last, ''))
+ ' ' + LTRIM(RTRIM(ISNULL(r.rm2first, '')) + ' ') + RTRIM(ISNULL(r.rm2last, '')) + ' ' + LTRIM(RTRIM(ISNULL(r.rm3first, '')) + ' ')
+ RTRIM(ISNULL(r.rm3last, '')) + ' ' + LTRIM(RTRIM(ISNULL(r.rm4first, '')) + ' ') + RTRIM(ISNULL(r.rm4last, '')) + ' ' + LTRIM(RTRIM(ISNULL(r.rm5first,
'')) + ' ') + RTRIM(ISNULL(r.rm5last, '')) AS Residents,
a.SADDR1 AS taddr1,
a.SADDR2 AS taddr2,
a.SCITY AS tcity,
a.SSTATE AS tstate,
a.SZIPCODE AS tzip,
RTRIM(LTRIM(t.SUNITCODE)) AS AptNum,
RTRIM(LTRIM(p.SADDR1)) AS PropertyName,
p.SADDR2, p.SCITY, p.SSTATE,
p.SZIPCODE,
pf.SPROPFIELDS AS Phone,
pf1.SPROPFIELDS AS Email
FROM PROPERTY p INNER JOIN
TENANT t ON p.HMY = t.HPROPERTY LEFT OUTER JOIN
roommates r ON t.HMYPERSON = r.tenhmy INNER JOIN
UNIT u ON p.HMY = u.HPROPERTY AND t.HUNIT = u.HMY INNER JOIN
PROP_FIELD pf ON p.HMY = pf.HPROP INNER JOIN
ADDR a ON u.HMY = a.HPOINTER INNER JOIN
PROP_FIELD pf1 ON p.HMY = pf1.HPROP
WHERE (t.ISTATUS IN (0, 3, 4)) AND (t.DTLEASETO < GETDATE()) AND (ISNULL(t.DTMOVEOUT, GETDATE()) = GETDATE()) AND
(pf1.ICOUNTER = 3) AND (pf.ICOUNTER = 1)
AND t.hProperty = 113
ORDER BY RTRIM(LTRIM(t.SUNITCODE))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top