borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (page totals in crystal reports)Next Topic (Placing images and text on a crystal report) New Topic New Poll Post Reply
AndreaVB Forum : Reporting tools : placing images in crytal report
Poster Message
krkumar50
Level: Trainee

Registered: 23-09-2006
Posts: 3

icon placing images in crytal report

'pl help me
' this code  is for displaying images in crytal report from vb with sql server. but image is not displayed.

database
------------
eno  ename photo
1        a       test.jpg
2        b       test1.bmp
-------------------------------

the problem is in the SECT_FORMAT function


error message is :

runtime error 9
subscript out of range

-------------------------------------

'code for module
Public cn As New ADODB.Connection

Dim cmd1 As New ADODB.Command
Dim rst1 As New ADODB.Recordset
Dim p1 As ADODB.Parameter

Dim db As craxdrt.Database
Dim rpt As craxdrt.Report
Dim appl As craxdrt.Application
Dim WithEvents sect As craxdrt.Section
  

Private Sub Form_Load()
    
    cn.Open "dsnpayroll"

    cmd1.ActiveConnection = cn
    cmd1.CommandType = adCmdStoredProc
    cmd1.CommandText = "usp_searchData"

    Set appl = New craxdrt.Application
    Set rpt = appl.OpenReport("d:\ReportImage" & "\Report1.rpt")
    Set db = rpt.Database
    Set sect = rpt.Sections("Section5")

    If rst1.State = 1 Then rst1.Close
    Set p1 = cmd1.CreateParameter("sql", adVarChar, adParamInput, 400)
    cmd1.Parameters.Append p1
    p1.Value = "select  *from employee"
    Set rst1 = cmd1.Execute

    cmd1.Parameters.Delete "sql"
    Set p1 = Nothing
    If rst1.State = 1 Then rst1.Close

    CRViewer1.ReportSource = rpt
    CRViewer1.ViewReport
    CRViewer1.Zoom 1
    Me.WindowState = 2
    
    Screen.MousePointer = vbHourglass
    Screen.MousePointer = vbDefault
    
    
End Sub

Private Sub Form_Resize()
    CRViewer1.Top = 0
    CRViewer1.Left = 0
    CRViewer1.Height = ScaleHeight
    CRViewer1.Width = ScaleWidth
End Sub

Private Sub sect_Format(ByVal pFormattingInfo As Object)
Dim bmp As StdPicture

    With sect.ReportObjects
          
        Set bmp = LoadPicture("d:\ReportImage\Photo\" & .Item("Field3").Value)                        'path for images
        Set .Item("Picture1").FormattedPicture = bmp
          
    End With
End Sub
  

thanks a lot



17-12-2006 at 11:04 AM
View Profile Send Email to User Show All Posts | Quote Reply
Aeric
Level: Sage


Registered: 16-06-2003
Posts: 53
icon Re: placing images in crytal report

The problem is occur at the following line:

        Set bmp = LoadPicture("d:\ReportImage\Photo\" & .Item("Field3").Value)                        'path for images


or

Set .Item("Picture1").FormattedPicture = bmp


To fix this, you have to use VB Report Designer to open the external Crystal Reports file to see the object's Name. It maybe not named as Field3 and Picture1.

18-12-2006 at 02:13 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
AndreaVB Forum : Reporting tools : placing images in crytal report
Previous Topic (page totals in crystal reports)Next Topic (Placing images and text on a crystal report) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder