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!

to display crystal reports 8.5 in VB6 2

Status
Not open for further replies.

graphix03

Technical User
Oct 8, 2003
189
US
hello,
i have a lot of access reports
that i need to migrate to crystal
and have them display in vb6.
the reports have been redesigned in
crystal, but I don't know how to
display them in vb6 efficiently.

Meaning, the code below is good to show
one report, but what if I have so many
of them need to be displayed, to copy and
pasted this code below over and over
again for 200 reports
does not sound efficient to me.

Is there a better way to show crystal report
in vb? if menu does not work, would list box
works?

see, the code below is for each click on each
report I list on the menu.

Private Sub mnuReport1_Click()

Set mCrystal = New CRAXDRT.Application
Set mReport = mCrystal.OpenReport("H:\report1.rpt")

CRViewer1.ReportSource = mReport
CRViewer1.ViewReport

Set mCrystal = Nothing
Set mReport = Nothing

End Sub

thanks so much if you have any input.

 
Here's the Sub I use to read from a Reports folder, and dynamically add each report to a menu. If you'd rather use a ListBox, then you should be able to adapt this without much trouble.
Code:
Public Sub CreateReportList()
'load the reports
'if there aren't any reports, then the menu should not be visible

    Dim i As Integer, j As Integer
    Dim fs, f, fl, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    If Not fs.FolderExists(App.Path & "\Reports") Then
        mnuReports.Visible = False
        Set fs = Nothing
        Exit Sub
    End If
    Set f = fs.getfolder(App.Path & "\Reports")
    Set fc = f.Files
    For Each fl In fc
        If fl.Type = "Crystal Report" Or Right(fl.Name, 4) = ".rpt" Then
            If i > 0 Then
                Load mnuReportsList(i)
            End If
            
            'Format the file name for display
            mnuReportsList(i).Caption = Replace(fl.Name, "_", " ")
            mnuReportsList(i).Caption = Left(mnuReportsList(i).Caption, Len(mnuReportsList(i).Caption) - 4)
            mnuReportsList(i).Tag = fl.Path
            i = i + 1
        End If
    Next

End Sub
-dave
 
hi dave, thanks so much for helping me.
I believe you have answered my prayer.
i'll try this but i think i definitely
got what i've been looking. I've been
asked everywhere and books but there
was never a sample for me to have an idea
how to deal with listing more than one
report.

thank you thank you thank you.
you really made my day. god bless you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top