borderAndreaVB free resources for Visual Basic developersborder

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

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

(Pages: Previous Page Next Page 1 2 3 ) Print This Topic
Next Topic (Resetting Page Numbering) New Topic New Poll Post Reply
AndreaVB Forum : Reporting tools : Placing images and text on a crystal report
Poster Message
baachi
Level: Protégé

Registered: 16-06-2005
Posts: 4

icon Re: Placing images and text on a crystal report

quote:
Aeric wrote:
Have you tried other name? I mean, instead using Section3, try to use name like Sect3. I suspect it's name may have conflict or sharing memory with Section3 of the report.


I tried other name like ....
====
Dim WithEvents Sec3 As CRAXDRT.Section
====
I got the same error even if i remove the following statement after asiging the report...

    Set Sec3 = crxReport.Sections(3)

I think the error from declaration part.....

pl...
Sudha



[Edited by baachi on 22-07-2005 at 07:59 AM GMT]

____________________________
Rao N S
22-07-2005 at 07:58 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

I am not sure what is the problem. Since you say it is something wrong with the declaration, then you may be right.

I have a suggestion, don't know you have tried before or not.

Try to change the Dimension (Dim) to Private. I think Private may have more memories.

==============================
Private WithEvents Sec3 As CRAXDRT.Section
==============================

[Edited by Aeric on 23-07-2005 at 09:35 AM GMT]

23-07-2005 at 01:34 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
tutilicapi
Level: Trainee

Registered: 31-08-2005
Posts: 1
icon Re: Placing images and text on a crystal report

Hello,
Sometime like this but in .net


Private Sub cmd_Report_Click()

    'Open the Report
    Set crxApplication = New CRAXDRT.Application
    Set crxReport = crxApplication.OpenReport(App.Path & "\withphoto.rpt")
    
    'Set Sectio3 to the Detail section of the report
    Set Section3 = crxReport.Sections(3)

    'Discard saved data
    crxReport.DiscardSavedData

    ' asign the recordset to the report    
    crxReport.Database.SetDataSource rsTemp, 3, 1
    
    With frmView
        .Refresh
        .Caption = g_RptType & " Wise Report"
        .CRViewer1.ReportSource = crxReport
        .CRViewer1.ViewReport
    End With
    
    Screen.MousePointer = vbDefault
    Set rsTemp = Nothing
    Set crxApplication = Nothing
    Set crxReport = Nothing
    Set Section3 = Nothing
    Set rptObject = Nothing

End Sub

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

    With Section3.ReportObjects
        'Check picture file exist or not using
        'FileSystemObject.FileExists
        If Dir$(App.Path & "\images\" & .Item("Field9").Value) = Empty Then
            Set bmp = LoadPicture(App.Path & "\images\null.jpg")
        Else
            Set bmp = LoadPicture(App.Path & "\images\" & .Item("Field9").Value)
        End If
        Set .Item("Picture1").FormattedPicture = bmp
    End With
    Set bmp = Nothing
End Sub

' end of the code

Thank people

31-08-2005 at 05:57 PM
View Profile Send Email to User Show All Posts | Quote Reply
ben.ooi
Level: Trainee

Registered: 01-09-2005
Posts: 3
icon Re: Placing images and text on a crystal report

quote:
Goran wrote:
It should be something like this:

rpt.sections("Section1").reportobjects("picture1")=loadpicture("c:\test.bmp")


if you want to see what method does picture object has. do this:

dim pic as craxdrt.oleobject

    pic.formattedpicture.   - to display properties and methods




hi,
   How i know the image to put in the rpt.sections("Section1"), not rpt.sections("Section2") or others. What i means is, how can i  determine the section if i want to put my pic in details section ??
Thnks in advances!!
01-09-2005 at 04:31 AM
View Profile Send Email to User Show All Posts | Quote Reply
agrina_s
Level: Trainee

Registered: 19-09-2005
Posts: 2
icon Re: Placing images and text on a crystal report

Hi !

I'm also having the same problem with Aeric, and I've tried the code in your attachement Thanx a lot for it.

But I'm having an error.... Runtime error 70: permission denied.

What's causing this error ? And I'm not using external crystal report but internal crystal report.

Thanx a lot for your help

Best Regards,
Agrina

19-09-2005 at 07:37 AM
View Profile Send Email to User Show All Posts | Quote Reply
patriciahsatler
Level: Trainee

Registered: 05-10-2005
Posts: 1
icon Re: Placing images and text on a crystal report

help me please ...

look error messagem in anexed!

Dim WithEvents Section3 As CRAXDRT.Section

Compile error:
invalid attribute in Sub or Function.

05-10-2005 at 02:38 PM
View Profile Send Email to User Show All Posts | Quote Reply
maob85
Level: Trainee

Registered: 12-01-2006
Posts: 1
icon Re: Placing images and text on a crystal report

Hi. I'm Using Crystal Report 8 Control Instead Crystal Report VIEWER Control... How can I do to load a pic in the way you describe above with the control I'm Using? This drives me nuts....

Thanks in advance....

12-01-2006 at 05:32 PM
View Profile Send Email to User Show All Posts | Quote Reply
zen
Level: Trainee

Registered: 18-04-2006
Posts: 3
icon Re: Placing images and text on a crystal report

I am having a problem with the code shown below. Actually there wil be no error occur when u try to run it but the problem is, there is no picture displayed in the report viewer.

Can anyone..Help me...

Dim appl As CRAXDRT.Application
Dim rpt As CRAXDRT.Report
Dim WithEvents sect As CRAXDRT.Section

Private sub Form_Load()
Set appl = New CRAXDRT.Application
    Set rpt = appl.OpenReport(App.Path & "\Report1.rpt")
        rpt.Application.LogOnServer "PDSODBC.DLL", sDatabase, sTable, sUserName, sUserPwd
    Set sect = rpt.Sections("Section5")
    
  Screen.MousePointer = vbHourglass
  CRViewer1.ReportSource = rpt
  CRViewer1.ViewReport
  Screen.MousePointer = vbDefault
End sub

Private Sub sect_format(ByVal pFormattingInfo As Object)
  Dim bmp As StdPicture
     With sect.ReportObjects
       Set bmp = LoadPicture(vfilepath & "5549.jpg")
       Set .Item("Picture3").FormattedPicture = bmp
     End With
End Sub

18-04-2006 at 02:47 AM
View Profile Send Email to User Show All Posts | Quote Reply
zen
Level: Trainee

Registered: 18-04-2006
Posts: 3
icon Re: Placing images and text on a crystal report

I am having a problem with the code shown below. Actually there wil be no error occur when u try to run it but the problem is, there is no picture displayed in the report viewer.

Can anyone..Help me...

Dim appl As CRAXDRT.Application
Dim rpt As CRAXDRT.Report
Dim WithEvents sect As CRAXDRT.Section

Private sub Form_Load()
Set appl = New CRAXDRT.Application
    Set rpt = appl.OpenReport(App.Path & "\Report1.rpt")
        rpt.Application.LogOnServer "PDSODBC.DLL", sDatabase, sTable, sUserName, sUserPwd
    Set sect = rpt.Sections("Section5")
    
  Screen.MousePointer = vbHourglass
  CRViewer1.ReportSource = rpt
  CRViewer1.ViewReport
  Screen.MousePointer = vbDefault
End sub

Private Sub sect_format(ByVal pFormattingInfo As Object)
  Dim bmp As StdPicture
     With sect.ReportObjects
       Set bmp = LoadPicture(vfilepath & "5549.jpg")
       Set .Item("Picture3").FormattedPicture = bmp
     End With
End Sub

18-04-2006 at 02:47 AM
View Profile Send Email to User Show All Posts | Quote Reply
zen
Level: Trainee

Registered: 18-04-2006
Posts: 3
icon Re: Placing images and text on a crystal report

I am having a problem with the code shown below. Actually there wil be no error occur when u try to run it but the problem is, there is no picture displayed in the report viewer.

Can anyone..Help me...

Dim appl As CRAXDRT.Application
Dim rpt As CRAXDRT.Report
Dim WithEvents sect As CRAXDRT.Section

Private sub Form_Load()
Set appl = New CRAXDRT.Application
    Set rpt = appl.OpenReport(App.Path & "\Report1.rpt")
        rpt.Application.LogOnServer "PDSODBC.DLL", sDatabase, sTable, sUserName, sUserPwd
    Set sect = rpt.Sections("Section5")
    
  Screen.MousePointer = vbHourglass
  CRViewer1.ReportSource = rpt
  CRViewer1.ViewReport
  Screen.MousePointer = vbDefault
End sub

Private Sub sect_format(ByVal pFormattingInfo As Object)
  Dim bmp As StdPicture
     With sect.ReportObjects
       Set bmp = LoadPicture(vfilepath & "5549.jpg")
       Set .Item("Picture3").FormattedPicture = bmp
     End With
End Sub

18-04-2006 at 02:47 AM
View Profile Send Email to User Show All Posts | Quote Reply
bluetuz
Level: Trainee

Registered: 25-05-2006
Posts: 2
icon Re: Placing images and text on a crystal report

Hi, I have been checking your example code to show images in a report that collects the image from a database field that contains the path to the image. I have this code:

        Dim cn As ADODB.Connection
        Dim rs1 As ADODB.Recordset
        cn = CreateObject("ADODB.Connection")
        cn.Open(ConexionReporte)
        rs1 = CreateObject("ADODB.Recordset")
        rs1.Open(SQLReporte, cn)

       rpt = appl.OpenReport("C:\Documents and Settings\David\Mis documentos\Visual Studio 2005\C-Orona\C-Orona\pm.rpt")
        rpt.Database.SetDataSource(rs1)
        sect = rpt.Sections("Section3")
        rptVisor.ReportSource = rpt

The problem is that when I run the application I get a message that says "Invalid Report Source" from the last code line. rptVisor is a Report Viewer control existing in the form.
Could you help me?
Thanks a lot

25-05-2006 at 09:18 PM
View Profile Send Email to User Show All Posts | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

Dear Zen,

I think you should change the line
     Set bmp = LoadPicture(vfilepath & "5549.jpg")
to
     Set bmp = LoadPicture(vfilepath & "\5549.jpg")

26-05-2006 at 02:27 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

Hi bluetuz
I think the problem is the object rpt itself not rptVisor. Maybe the path is incorrect or the file type/version is not supported causing appl unable to open the report correctly. Try put the report inside the application folder and use App.Path in your code.

26-05-2006 at 02:36 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

quote:
agrina_s wrote:
Hi !

I'm also having the same problem with Aeric, and I've tried the code in your attachement Thanx a lot for it.

But I'm having an error.... Runtime error 70: permission denied.

What's causing this error ? And I'm not using external crystal report but internal crystal report.

Thanx a lot for your help

Best Regards,
Agrina


Is the permission denied when you try to read/open the database? Do you set a password for your database?
26-05-2006 at 02:39 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

quote:
ben.ooi wrote:
quote:
Goran wrote:
It should be something like this:

rpt.sections("Section1").reportobjects("picture1")=loadpicture("c:\test.bmp")


if you want to see what method does picture object has. do this:

dim pic as craxdrt.oleobject

    pic.formattedpicture.   - to display properties and methods




hi,
   How i know the image to put in the rpt.sections("Section1"), not rpt.sections("Section2") or others. What i means is, how can i  determine the section if i want to put my pic in details section ??
Thnks in advances!!


Try open the report using Visual Basic, Report Designer. It will show the name of each Section in the Designer window.
26-05-2006 at 02:44 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
yan29
Level: Trainee

Registered: 30-05-2006
Posts: 1
icon Re: Placing images and text on a crystal report

hi !

this code has saved my life !

works wonderful!

tkx

30-05-2006 at 04:27 PM
View Profile Send Email to User Show All Posts | Quote Reply
deepakkhot
Level: Trainee

Registered: 23-06-2006
Posts: 2
icon Re: Placing images and text on a crystal report

i  want to dispaly images in my crysatl reports .

only image path is stored in  database and i am using external report .

23-06-2006 at 02:55 AM
View Profile Send Email to User Show All Posts | Quote Reply
deepakkhot
Level: Trainee

Registered: 23-06-2006
Posts: 2
icon Re: Placing images and text on a crystal report

[thanks a lot solved my problem)

23-06-2006 at 03:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

quote:
deepakkhot wrote:
i  want to dispaly images in my crysatl reports .

only image path is stored in  database and i am using external report .


Please try my sample project
Or download this attachment.

This sample is using VB6, MS Access 2000 database and Crystal Reports 8.5 Developer and you can load image of file type JPG, GIF and BMP where image files are located inside application directory and report will load the images by reading the path from the database.
23-06-2006 at 03:12 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

A member asked me if he wants to use my sample with MS SQL server. So i think he just need to change the connection string to SQL Server.

Open my sample project and change the database connection like below:


'Put this in module and set as Public
Public con As ADODB.Connection

'Create a function for the database connection
Public Function BeginDatabase() As Boolean
On Error GoTo checkErr
    Set con = New ADODB.Connection
    con.Open "Provider=SQLOLEDB.1;Password=" & strPassword & ";Persist Security Info=True;User ID=" & strUserName & ";Initial Catalog= " & strDatabaseName & ";Data Source=" & strServerName
    con.Open
    BeginDatabase = True
    Exit Function
checkErr:
    BeginDatabase = False
End Function

'Call the function in Form_Load()
Private Sub Form_Load()
    If BeginDatabase = False Then
        Msgbox "Error connecting to SQL Server!", vbExclamation
        Unload Me 'or use Exit Sub
    End If
En Sub


[Edited by Aeric on 14-12-2006 at 05:47 PM GMT]

14-12-2006 at 09:44 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
rays
Level: Trainee

Registered: 22-11-2007
Posts: 3
icon Re: Placing images and text on a crystal report

quote:
Aeric wrote:
A member asked me if he wants to use my sample with MS SQL server. So i think he just need to change the connection string to SQL Server.

Open my sample project and change the database connection like below:


'Put this in module and set as Public
Public con As ADODB.Connection

'Create a function for the database connection
Public Function BeginDatabase() As Boolean
On Error GoTo checkErr
    Set con = New ADODB.Connection
    con.Open "Provider=SQLOLEDB.1;Password=" & strPassword & ";Persist Security Info=True;User ID=" & strUserName & ";Initial Catalog= " & strDatabaseName & ";Data Source=" & strServerName
    con.Open
    BeginDatabase = True
    Exit Function
checkErr:
    BeginDatabase = False
End Function

'Call the function in Form_Load()
Private Sub Form_Load()
    If BeginDatabase = False Then
        Msgbox "Error connecting to SQL Server!", vbExclamation
        Unload Me 'or use Exit Sub
    End If
En Sub


[Edited by Aeric on 14-12-2006 at 05:47 PM GMT]


Is there anyway to put dynamic image in external crystal report with file path saved in database using VB.Net. Coz i am getting error in folling code

Dim appl As craxdrt.application
    Dim rpt As craxdrt.report
    Dim WithEvents sect As craxdrt.section
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim rpt As New crpt1
        rpt.Section3.ReportObjects("picture1") = loadpicture("c:\test.bmp")
    End Sub

getting error
F:\testproj\test\test\Form1.vb(62): Type 'craxdrt.application' is not defined.
23-11-2007 at 03:28 AM
View Profile Send Email to User Show All Posts | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

Error:
F:\testproj\test\test\Form1.vb(62): Type 'craxdrt.application' is not defined.

The problem is you need to reference Crystal Reports Designer Component before you can use it.

I hope the following link would help: VB.NET and ActiveX Controls


Aeric

23-11-2007 at 03:47 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 776
icon Re: Placing images and text on a crystal report

Aeric, can I ask you to put down a tutorial about how passing a picture path to an existing report in order to dinamically show pictures on it? IMHO it would be largely useful, and in fact this thread has become like an article on it. But it's difficult to locate infos thru it, as it has first conceived to solve some specific problems. I would like you to plainly explain all the logic and the process, as you seem having deeply taken it. So please, post a tutorial speech on Andrea's Articles section. Of course if you want and if you got time.

____________________________
Real Programmer can count up to 1024 on his fingers

23-11-2007 at 06:43 PM
View Profile Send Email to User Show All Posts | Quote Reply
rays
Level: Trainee

Registered: 22-11-2007
Posts: 3
icon Re: Placing images and text on a crystal report

quote:
Aeric wrote:
Well the link provided the dll to be created, means that if i want a dynamic image in vb.net i have to intermediate vb and then crystal report. But isnt there any way out to add reference Crystal Reports Designer Component in vb.net.


Error:
F:\testproj\test\test\Form1.vb(62): Type 'craxdrt.application' is not defined.

The problem is you need to reference Crystal Reports Designer Component before you can use it.

I hope the following link would help: VB.NET and ActiveX Controls


Aeric

23-11-2007 at 07:48 PM
View Profile Send Email to User Show All Posts | Quote Reply
rays
Level: Trainee

Registered: 22-11-2007
Posts: 3
icon Re: Placing images and text on a crystal report

quote:
rays wrote:

Well the link provided the dll to be created, means that if i want a dynamic image in vb.net i have to intermediate vb and then crystal report. But isnt there any way out to add reference Crystal Reports Designer Component in vb.net.



quote:
Aeric wrote:

Error:
F:\testproj\test\test\Form1.vb(62): Type 'craxdrt.application' is not defined.

The problem is you need to reference Crystal Reports Designer Component before you can use it.

I hope the following link would help: VB.NET and ActiveX Controls


Aeric



25-11-2007 at 06:32 PM
View Profile Send Email to User Show All Posts | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

quote:
yronium wrote:
Aeric, can I ask you to put down a tutorial about how passing a picture path to an existing report in order to dinamically show pictures on it? IMHO it would be largely useful, and in fact this thread has become like an article on it. But it's difficult to locate infos thru it, as it has first conceived to solve some specific problems. I would like you to plainly explain all the logic and the process, as you seem having deeply taken it. So please, post a tutorial speech on Andrea's Articles section. Of course if you want and if you got time.

Thanks to the moderator for this suggestion. I am using VB6 all the way and haven't touch VB.Net before. So, I can make a tutorial in VB6 only. I hope I will do it soon.

Aeric
26-11-2007 at 01:18 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

quote:
rays wrote:
quote:
rays wrote:

Well the link provided the dll to be created, means that if i want a dynamic image in vb.net i have to intermediate vb and then crystal report. But isnt there any way out to add reference Crystal Reports Designer Component in vb.net.



quote:
Aeric wrote:

Error:
F:\testproj\test\test\Form1.vb(62): Type 'craxdrt.application' is not defined.

The problem is you need to reference Crystal Reports Designer Component before you can use it.

I hope the following link would help: VB.NET and ActiveX Controls


Aeric





As I mentioned above, I haven't seen the IDE for latest VS.Net so I am not sure how to reference the component into the project. What I learned is that VS.Net initially was mean to develop application without the developer reference to any DLL. Perhaps the latest VS.Net doesn't support certain version of Crystal Reports. Using the latest version of Crystal Reports may solve the problem of incompatibility.

Aeric
26-11-2007 at 01:26 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 776
icon Re: Placing images and text on a crystal report

quote:
Aeric wrote:Thanks to the moderator for this suggestion. I am using VB6 all the way and haven't touch VB.Net before. So, I can make a tutorial in VB6 only. I hope I will do it soon.
VB6 is OK. You're still using it, just like the 50 percent of developers in the world. That's why MS doesn't release VB6's license for free, though it's not developped yet since seven years nor supported since three years. IMHO it'll take a bit longer again to make VB6 tutorials useless.

Hope you can. This post has grown too much to be easily readable and sometimes the server stucks to view the latest posts on the second page.


____________________________
Real Programmer can count up to 1024 on his fingers
26-11-2007 at 07:55 PM
View Profile Send Email to User Show All Posts | Quote Reply
Aeric
Level: Professor


Registered: 16-06-2003
Posts: 72
icon Re: Placing images and text on a crystal report

quote:
yronium wrote:
quote:
Aeric wrote:Thanks to the moderator for this suggestion. I am using VB6 all the way and haven't touch VB.Net before. So, I can make a tutorial in VB6 only. I hope I will do it soon.
VB6 is OK. You're still using it, just like the 50 percent of developers in the world. That's why MS doesn't release VB6's license for free, though it's not developped yet since seven years nor supported since three years. IMHO it'll take a bit longer again to make VB6 tutorials useless.

Hope you can. This post has grown too much to be easily readable and sometimes the server stucks to view the latest posts on the second page.


I 'll do it but give me a bit of time.

quote:
Real Programmer can count up to 1024 on his fingers
I wish I can do so too...    
27-11-2007 at 01:09 AM
View Profile Send Email to User Show All Posts Visit Homepage ICQ | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 776
icon Re: Placing images and text on a crystal report

quote:
Aeric wrote:
I 'll do it but give me a bit of time.
Please take all the time you need, and don't feel in hurry for me.

quote:
Aeric wrote:
quote:
Real Programmer can count up to 1024 on his fingers
I wish I can do so too...    
Really you can't? So, in order to help you, I'll provide another popular sentence:
"There are 10 kinds of people: those who understand binary and those who don't."


[Edited by yronium on 27-11-2007 at 12:07 PM GMT]

____________________________
Real Programmer can count up to 1024 on his fingers
27-11-2007 at 11:04 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Reporting tools : Placing images and text on a crystal report
Next Topic (Resetting Page Numbering) New Topic New Poll Post Reply
(Pages: Previous Page Next Page 1 2 3 )
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-2012 Andrea Tincaniborder