DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Insert/Loading Pictures to Crystal Reports given a Path from Database in VB6

  1. #1
    Join Date
    Dec 2004

    Question Insert/Loading Pictures to Crystal Reports given a Path from Database in VB6

    I want to display picture of every member of a club membership system to a Crystal Report. I found a sample code from the Crystal Reports Sample Code directory.

    Private Sub Section10_Format(ByVal pFormattingInfo As Object)
        Dim bmpHold As StdPicture               ' object to hold the bitmap
            ' Set our variable to an bitmap
            Set bmpHold = LoadPicture(App.Path & "\" & Field1.Value)
            ' Set the height and width of the Report object equal to the actual values for
            ' the bitmap - the StdPicture object defaults to HiMetric, the Report uses twips
            ' Set the bitmap on the Report equal to the variable
            Set Picture1.FormattedPicture = bmpHold
            Picture1.Height = bmpHold.Height * 567 / 1000   ' convert from HiMetric to Twips
            Picture1.Width = bmpHold.Width * 567 / 1000     ' convert from HiMetric to Twips
    End Sub
    Field1 value is retrieve from MS Access Database which display the name of the picture file where the pictures are stored in the Application directory. I don't want store the picture as OLE object into Database.

    The code above is working but only if I include a report in the Designers module. Is there anyone knows how to do it if I use external *.rpt file for the report?

  2. #2
    Join Date
    Jul 2007

    Loading Pictures to Crystal Reports from VB6

    I do this from a VB application involving rental properties...

    To do this, first set some variables at a global level.

    Private oCR As New CRAXDRT.Application
    Private Rpt As CRAXDRT.Report
    Private WithEvents rptSection As CRAXDRT.Section

    Then set the Rpt to your report within a subroutine.

    Private Sub cmdViewRpt()
    Set Rpt = oCR.OpenReport("Path & Report.rpt")
    End Sub

    Then create a subroutine like the following:

    Private Sub rptSection_format(ByVal pFormattingInfo As Object)
    On Error Resume Next
    If Len(Rpt.Sections("PageHeaderSection1").ReportObjects.Item("imgFile1").Value) > 0 Then
    Set Rpt.Sections("PageHeaderSection1").ReportObjects.Item("PicUnit").FormattedPicture = _
    LoadPicture(sImgDir & Rpt.Sections("PageHeaderSection1").ReportObjects.Item("imgFile1").Value)
    End If
    End Sub

    This has worked for me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center