 |
(Pages: 1 2 3 ) |
 |
shyamrama23 Level: Protégé
 Registered: 16-09-2004 Posts: 5
|
Placing images and text on a crystal report
Hi,
My problem is I need to place several images on a crystal report of size A3 and of size 9.2 *5.8.On an A3 paper we can get 7 * 3 = 21 images (3 horizontally and 7 vertically). All the images are different. Plz tell me how can I achieve this?
thanking you
Shyam
|
|
08-02-2005 at 03:49 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
Will images be taken from database or you need to set the path to them?
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
08-02-2005 at 11:32 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
If I am not mistaken, report has Sections collection, and section object has Report objects collection, which youcan use to access picturebox.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
06-04-2005 at 10:55 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
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 |
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
07-04-2005 at 06:49 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
I didnt understand you quite well.... What do you mean by field change? You can use the code before the report is shown....
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
08-04-2005 at 07:07 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
Aha... Now I got you. Try this. First you need to put OleObject on your report and place field object with the path to the image in the same section as OleObject.
' declare objects on the form where crystal viewer is
dim appl as craxdrt.application
dim rpt as craxdrt.report
dim withevents sect as craxdrt.section
' change section10 to name of the section where picture is displayed
private sub form_load()
set appl=new craxdrt.applicaiton
set rpt=appl.openreport(app.path & "\reportname.rpt")
set sect=rpt.sections("Section10")
end sub |
I cant recall what is the parameter name of the format event below, but when you declare section object WithEvents, as we did, then rpt object is shown in forms code window, just like any other control, so just as you would insert keypressevent for textbox, you can insert format event for section object.
private sub sect_format(..............)
with sect.reportobjects
.item("picture1").setolelocation .item("fldPath").value
end sub |
picture1 is the name of the oleobject you inserted, and fldpath is the name of the table field where you have path to image, so you should change those two with correct names.
I didnt put rest of the code for showing report, I suppose you do have rest of it.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
09-04-2005 at 02:59 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
As for the objects names, you can easily get their names in report designer, right click on the object, select Format_xxx option, and there you have object name which you can also change.
From VB environment, go to debug mode (usually by creating a breakpoint after the line Set rpt = CRXApp.OpenReport(.....) ), and in debug window you can use these commands:
| ? rpt.sections(1).reportobjects(1).name |
will display first object in first section
| ? rpt.sections(3).reportobjects(5).name |
will display fifth object in third section, etc, etc
In these two collections (sections and reportobjects), objects start with index 1, not 0
[Edited by Goran on 14-04-2005 at 12:23 AM GMT]
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
13-04-2005 at 11:19 PM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
Sorry, I always found this option useful, since user can mark some value, and not to get lost in many numbers, so I never wanted to turn it off. Now I dont have VB6 with me to see if there is such an option, so you will have to do a research by yourself.If there is such an option I think it should be a property of crystal report viewer control.
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
17-04-2005 at 10:42 PM |
|
|
sathya Level: Trainee
 Registered: 20-04-2005 Posts: 1
|
Re: Placing images and text on a crystal report
hi,
i tried the same that Aeric did.
function setImage()
{
crSections = crRpt.Sections;
crOleObj = crRpt.oleObject;
for(var xx = 1;xx<crSections.Count;xx++)
{
crSection = crSections.Item(xx);
crReportObjs = crSection.ReportObjects;
for(var yy=1;yy<=crReportObjs.Count;yy++)
{
if(crReportObjs.Item(yy).Kind == 6)
{
crOleObj = crReportObjs.Item(yy)
crOleObj.setolelocation("a.bmp");
}
}
}
}
but i get the permission denied ..can u help
-Sathya
|
|
20-04-2005 at 01:42 PM |
|
|
paulerts Level: Trainee
 Registered: 06-06-2005 Posts: 1
|
Re: Placing images and text on a crystal report
paulerts@yahoo.com
I have been having problems with putting an image in my report...I am using an external .rpt file that is being called from a VB program(CRViewer)...my vb code is listed below, i am using a UDL file for my connection so when I created the report I used OLE DB to generate the tables I will be using in my report:
'Dim db As CRAXDRT.Database
Dim Report As CRAXDRT.Report
Dim Crystal As CRAXDRT.Application
Dim WithEvents sect As CRAXDRT.Section
Dim CONN As ADODB.Connection
Function Connect() As Boolean
On Error GoTo ErrMsg
'If Not (CONN Is Nothing) Then Exit Function
Set CONN = Nothing
Set CONN = New ADODB.Connection
CONN.CursorLocation = adUseClient CONN.ConnectionString = "File Name=" & App.Path & "\CONN.UDL"
CONN.Mode = adModeReadWrite
CONN.ConnectionTimeout = 1000
CONN.CommandTimeout = 1000
CONN.Open
CONN.Execute "SET QUOTED_IDENTIFIER OFF"
Connect = True
Exit Function
ErrMsg:
Connect = False
End Function
Private Sub Form_Load()
On Error GoTo ErrMsg
Dim rst As New ADODB.Recordset
Dim pic As OLEObject
Screen.MousePointer = vbHourglass
If Not Connect Then
' 'failed to connect
MsgBox "UNABLE TO CONNECT"
End If
CRViewer.DisplayBorder = False
CRViewer.DisplayTabs = False
CRViewer.EnableDrillDown = False
CRViewer.EnableRefreshButton = False
CRViewer.EnableSearchControl = True
Set Crystal = New CRAXDRT.Application
Set Report = Crystal.OpenReport(App.Path& "\Report4.rpt")
Set sect = Report.Sections(3)
rst.Open "SELECT CSKETCH01.IMAGENAME, CSKETCH01.IMAGE, SMSREPSO.SMS_Franchise_Desc, SMSREPSO.STRNG132, SMS_SOMS.Inquiry_Date, SMS_SOMS.SMS_Install_Date,SMSREPSO.SOPNUMBE, " & _
"SMSREPSO.SMS_WholeName, SMSREPSO.BRTHDATE, SMSREPSO.SMS_Whole_Service_Addres, " & _
"SMSREPSO.SMS_Billing_Address, SMSREPSO.Cell_Phone1, SMSREPSO.EMail, SMSREPSO.SMS_CRA," & _
"SMS_SOMS.SMS_Remarks, SMS_SOMS.SMS_Disconnection2, " & _
"SMS_SOMS.SMS_Reconnection, SMS_SOMS.SMS_Extension, SMS_SOMS.SMS_InspectionSurvey, SMS_SOMS.SMS_Transfer_Other," & _
"SMS_SOMS.SMS_Transfer_Same, SMS_SOMS.SMS_Others, SMS_SOMS.SMS_Internet, SMS_SOMS.SMS_Reception_Problem, " & _
"SMS_SOMS.SMS_Others_Reason, SMS_SOMS.SMS_Additional_MainTV, SMS_SOMS.SMS_Discon_Addl_MainTV," & _
"SMS_SOMS.SMS_ReceptionProb_Reason, RM00101.PHONE1, RM00101.PHONE2, RM00101.PHONE3, RM00101.COMMENT1," & _
"RM00101.COMMENT2, SMS_Cust.SMS_Landmark, RM00103.CUSTBLNC FROM CABLE.dbo.SMSREPSO INNER JOIN CABLE.dbo.SMS_SOMS ON " & _
"(CABLE.dbo.SMSREPSO.CUSTNMBR = CABLE.dbo.SMS_SOMS.CUSTNMBR AND CABLE.dbo.SMSREPSO.SMS_SO_No = CABLE.dbo.SMS_SOMS.SMS_SO_No) INNER JOIN CABLE.dbo.RM00101 ON (CABLE.dbo.SMS_SOMS.CUSTNMBR = CABLE.dbo.RM00101.CUSTNMBR)" & _
"INNER JOIN CABLE.dbo.RM00103 ON (CABLE.dbo.SMS_SOMS.CUSTNMBR = CABLE.dbo.RM00103.CUSTNMBR) INNER JOIN CABLE.dbo.SMS_Cust ON (CABLE.dbo.SMS_SOMS.CUSTNMBR = CABLE.dbo.SMS_Cust.CUSTNMBR)INNER JOIN CABLE.dbo.CSKETCH01 ON (CABLE.dbo.SMS_SOMS.CUSTNMBR = CABLE.dbo.CSKETCH01.CUSTNMBR)", CONN, 1, 1
Report.DiscardSavedData
Report.Database.SetDataSource rst, 3, 1
CRViewer.ReportSource = Report
CRViewer.ViewReport
Do While CRViewer.IsBusy
DoEvents
Loop
CRViewer.Zoom 100
Screen.MousePointer = vbDefault
Set Crystal = Nothing
Set Report = Nothing
Exit Sub
ErrMsg:
MsgBox "An error has occurred on properties: (Report Form Load)" & vbCr & "=================" & _
vbCr & Err.Description, vbCritical, "ProgTitle"
End Sub
Private Sub sect_Format(ByVal pFormattingInfo As Object)
Dim bmp As StdPicture
With sect.ReportObjects
'Check picture file exist or not using
'FileSystemObject.FileExists
Set bmp = LoadPicture(App.Path & "\begins4.jpg")
Set .Item("Picture1").FormattedPicture = bmp
End With
End Sub
I read Aeric's post and downloaded his file..I ran it and it worked fine so I kinda copied the way he coded it but still no luck...I keep getting "Runtime Error: 9 Subscript out of range" and when I click Debug it points to the last line which is
Set .Item("Picture1").FormattedPicture = bmp
At first I thought it was just on the Sections part(Reports.Sections(3))...I tried switching Sections from 1-5 but still the same result...
I don't get it why it that Aeric's program works and mine doesnt...Can you please help me? Please also send your reply to paulerts@yahoo.com..Thanks!
|
|
07-06-2005 at 08:23 AM |
|
|
baachi Level: Protégé
 Registered: 16-06-2005 Posts: 4
|
Re: Placing images and text on a crystal report
hi, I am using the above said code for printing labels with person image in the label itself...but...i faced one problem. the report will display few lable with image and it'll give error message like "Memory Full!"....
I want to print 11000 labels with image.
can anyone help this..pl.....
Sudhakara Rao Nalamothu
____________________________
Rao N S
|
|
18-06-2005 at 12:19 PM |
|
|
baachi Level: Protégé
 Registered: 16-06-2005 Posts: 4
|
Re: Placing images and text on a crystal report
Hi here is the which is i used in form. getting error "Memory Full"
'General Declaration
Dim crxReport As CRAXDRT.Report
Dim crxApplication As New CRAXDRT.Application
Dim WithEvents Section3 As CRAXDRT.Section
Dim rsTemp As New ADODB.Recordset
Dim sSql As String
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
'THIS IS FOR REPORT VIEWER FORM
'==================================
'Dim REPORT As New CrystalReport1
Dim Report As New CRAXDRT.Report
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
|
____________________________
Rao N S
|
|
20-06-2005 at 09:30 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Placing images and text on a crystal report
You have posted 2 different ways to show report. Which one are you using: internal or external report? And why do you need to print all the 11000 images at once? Dont you find that a little to much? No wonder your application has left out of memory. Try to be more selective, print it in batches of 1000 records, or even less...
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
20-06-2005 at 11:02 PM |
|
|
baachi Level: Protégé
 Registered: 16-06-2005 Posts: 4
|
Re: Placing images and text on a crystal report
Dear Sir,
I am using external Crystal Report to print labels with Image.
the entire code is working fine without image.
I get the "Memory Full" error when the following line appeared at declaration section.
=======
' Declare Section
Dim WithEvents Section3 As CRAXDRT.Section
=======
at the runtime it'll give "Memory Full" error. if I remove the above line it is working fine. If i declare it in Form_Load Event it won't accept.
at present i have only 20 records...
Pl...
____________________________
Rao N S
|
|
21-07-2005 at 01:03 PM |
|
|
|
|
 |
 |