For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Crystal Reports > June 2005 > How to use crystal report in VB6









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to use crystal report in VB6
Massive850

2005-06-03, 4:01 pm

OK,I created a report with Crystal Reports 9.0 that is named: report1.rpt on
a PC
Now I want to open it from within VB6 on an other PC.
In previous versions of VB I had just to add the Crystal Report Component on
a form (Crystl32.ocx) and write the apropriated code.
What am I supposed to do now?

Important:The PC which is running the VB6 application has nothing installed
relative with Crystal Reports...like it will be at the customer.

Maybe there is a run-time version of Crystal Reports ???

Sorry for my english.
Any help appreciated.....
John Smith

2005-06-03, 4:01 pm

hmm I don't know if this will help you (I use CR10 Dev Edition) 9 is
probably the same or similar. In anycase this may get you started. In vb6
(assuming you have CR9 installed on your development machine) go to project
Components click on the designer tab and select Crystal Reports 9 which
should add that designer to your add menu. Then in the Project Explorer
right click on your project and add a CR9 report. As far as installing it
on client machines that is another matter depending on what you use to
create your install apps. I use installshield with the cr merge modules to
install all the needed libraries.

Note this is if you want to be able to modify the cr report from within
vb6...

otherwise you could probably get away with having a form with CRviewer
control on it. (load it by right clicking on the control toolbar and
selecting Crystal Active X Report Viewer Library 9.0 or something like that)
With some code like below.

if you need more specific help getting it to work post more info.

Option Explicit
Dim mrptTemp As New rptShoda
Public mstrTitle As String
Public mstrJobId As String
Public mintLocationId As Integer
Public mstrUntrackedParts As String
Private Sub Form_Load()
On Error GoTo Form_Load_Err
Dim strTemp As String

Me.WindowState = 2

Screen.MousePointer = vbHourglass

mrptTemp.DiscardSavedData
' mrptTemp.Database.Tables(1).ConnectionProperties("User Id") = ""
' mrptTemp.Database.Tables(1).ConnectionProperties("Password") = ""
strTemp = Replace(mstrJobId, "'", "")
mrptTemp.ReportTitle = mstrTitle
mrptTemp.JobId.SetText (strTemp)
mrptTemp.ParameterFields.GetItemByName("JobId").AddCurrentValue
(mstrJobId)
mrptTemp.ParameterFields.GetItemByName("UntrackedParts").AddCurrentValue
(mstrUntrackedParts)
mrptTemp.ParameterFields.GetItemByName("LocationId").AddCurrentValue
(mintLocationId)
If RDINI_gintUsePrinterSetupDialog Then
mrptTemp.PrinterSetup Me.hwnd
End If

CRViewer1.ReportSource = mrptTemp
CRViewer1.ViewReport
CRViewer1.Zoom 100

While CRViewer1.IsBusy
DoEvents
Wend

Screen.MousePointer = vbDefault

Form_Load_Exit:
Exit Sub

Form_Load_Err:
MsgBox "Error! " & Err.Description & " (" & Err.Number & ").", vbCritical,
"Form_Load"
GoTo Form_Load_Exit
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set mrptTemp = Nothing
End Sub








"Massive850" <Massive850@discussions.microsoft.com> wrote in message
news:80235494-1F00-47D5-B31A-C5B3DB29353C@microsoft.com...
> OK,I created a report with Crystal Reports 9.0 that is named: report1.rpt

on
> a PC
> Now I want to open it from within VB6 on an other PC.
> In previous versions of VB I had just to add the Crystal Report Component

on
> a form (Crystl32.ocx) and write the apropriated code.
> What am I supposed to do now?
>
> Important:The PC which is running the VB6 application has nothing

installed
> relative with Crystal Reports...like it will be at the customer.
>
> Maybe there is a run-time version of Crystal Reports ???
>
> Sorry for my english.
> Any help appreciated.....



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com