Results 1 to 8 of 8

Thread: Crystal Reports Dynamic Image

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Crystal Reports Dynamic Image

    I'm trying to assign a dynamic image to a picture box in CR9. I started a new exe and played around with it before incorporating into my existing program. I was easily able to get it to work. When I imported it to my program i get a permission denied error from the picture1 control. It won't open the file. I do have a default image in the picture box that views fine. When I try to load the dynamic image it gets angry and throws the error.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Crystal Reports Dynamic Image

    What code are you using to load the new picture?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Re: Crystal Reports Dynamic Image

    Dim myPic As StdPicture
    Dim mypath
    mypath = Unit1Pic11.Value
    Set myPic = LoadPicture("C:\Program Files\Denali" & mypath)
    Set Picture1.FormattedPicture = (myPic)


    This worked on the exe I set up to test crystal reports.

    Once i get it to load again i need the image to stretch to the size of the picture box. I have spent hours searching on how to do it. You would think this would be something that would be thought of in development of CR. Is there a better program then Crystal Reports. I really don't want to use HTML it just doesn't look professional in a program like mine.

  4. #4
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: Crystal Reports Dynamic Image

    Check your load picture function as you might be missing a backslash, unless it is the first character in mypath...

    Next up, FormattedPicture is not a method of the VB6.0 PictureBox control. Is this control a CR Control? Or are you using .NET???

    Then it is time to look at either an image control, the render method of the stdPicture Object, BitBlt, or StretchBlt.



    Good Luck
    Option Explicit should not be an Option!

  5. #5

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Re: Crystal Reports Dynamic Image

    I'm using CR 9.22 Most the commands i see on the net concerning this problem do not show up- in the drop downs for the picture box. FormattedPicture is the only load command listed. stdPicture Object, BitBlt, or StretchBlt do not exist on the drop down as well. if I type these commands in I get an error. Could it be I'm missing a plug-in or something. There is only one option in CR to add a picture and thats the picture box control. I can't add any VB controls because they are all disabled when i have the CR page up. I looking into getting CR 8.5 maybe my VB6 is to old to handle 9.2. Could that be the problem.

  7. #7
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Crystal Reports Dynamic Image

    This is a small sample about how to change an image inside CR at running time

    Code:
    Option Explicit
    
    Dim Report          As CRAXDRT.Report
    Dim CRapp           As New CRAXDRT.Application
    Private WithEvents oSection As CRAXDRT.Section
    Dim pic1            As OLEObject
    Dim i               As Integer
    
    
    Private Sub Form_Load()
    
        'set the report
        Set Report = CRapp.OpenReport(App.Path + "\report1.rpt")
        'set the section object to the Details section of the report.
        Set oSection = Report.Sections("D")
    
        'Loop through the report objects and see if they are pictures
        For i = 1 To oSection.ReportObjects.Count
            'fully qualified croleobjects as craxdrt.crOleobject.. otherwise you will get the error - object variable not set
            ' if it is a CrOleObject then
            If oSection.ReportObjects(i).Kind = CRAXDRT.crOLEObject Then
                'Set the pic1 object to the Ole Report object
                Set pic1 = oSection.ReportObjects(i)
            End If
        Next i
    
        'view the report
        CrystalActiveXReportViewer1.ReportSource = Report
        CrystalActiveXReportViewer1.ViewReport
    
    End Sub
    
    
    'section format event: 
    'this event fires every time this section is generated by the report.
    Private Sub oSection_format(ByVal pFormattingInfo As Object)
        
        'load the image. this can be done dynamically if desired.
        Set pic1.FormattedPicture = LoadPicture(App.Path + "\test.bmp")
        
    End Sub
    
    
    Private Sub Form_Resize()
    
        CrystalActiveXReportViewer1.Top = 0
        CrystalActiveXReportViewer1.Left = 0
        CrystalActiveXReportViewer1.Height = ScaleHeight
        CrystalActiveXReportViewer1.Width = ScaleWidth
        
    End Sub
    JG

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Re: Crystal Reports Dynamic Image

    Why does it keep telling me "permission denied" ? It was working. I also took out the variable and put in the direct path. It says picture1 is denying permission.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width