|
-
Apr 5th, 2003, 12:17 PM
#1
Thread Starter
Member
Crystal Reports Image at Runtime [RESOLVED]
Hi,
I am using VB6, Crystal Reports 8.5, .rpt report files and the CRViewer to show the reports. Data source is either Access or SQL.
I need to be able to set an image in the report at runtime to the logo of the company selected. I am happy to use either an image in a directory (path provided) or an image stored in a database (passed by ADO Recordset).
Can anyone tell me how this can be done, or just start me off on the right track as I am stumped!!
Thanks in advance.
TC
I had posted this in the Crystal Reports section but to no avail!!
Last edited by TC99; Apr 6th, 2003 at 01:04 PM.
-
Apr 6th, 2003, 04:47 AM
#2
Thread Starter
Member
Does anybody know how to do this???
-
Apr 6th, 2003, 11:05 AM
#3
Addicted Member
Code:
Private Sub Section2_Format(ByVal pFormattingInfo As Object)
Set Picture1.FormattedPicture = LoadPicture("c:\aImages\inside.jpg")
end sub
See page 19 in this pdf file for a more detail example http://support.crystaldecisions.com/...8-ocxtordc.pdf
-
Apr 6th, 2003, 12:58 PM
#4
Thread Starter
Member
Hi Ken,
Thanks for the pdf link. It is just what I needed and works really well.
TC
-
Apr 7th, 2003, 08:27 PM
#5
Addicted Member
I can't make it work.
I tried your way of changing the image but I get a
"Permission denied."
error message.
VB Code:
Set crxPicObj = Report.Sections(2).ReportObjects.Item(18)
With rsTemp
If .State = adStateOpen Then
.Close
End If
.Source = "SELECT * FROM CSREPSETUP"
.Open
If .RecordCount <> 0 Then
sTemp = App.Path & "\Images\TempPic.jpg"
If Len(Dir(sTemp)) > 0 Then
Kill sTemp
End If
lngSize = 0
lngOffSet = 0
f = FreeFile
Open sTemp For Binary As #f
lngSize = rsTemp("Image").ActualSize
Do While lngOffSet < lngSize
bytChunk() = rsTemp("Image").GetChunk(CHUNKSIZE)
Put #f, , bytChunk()
lngOffSet = lngOffSet + CHUNKSIZE
Loop
Close #f
Set crxPicObj.FormattedPicture = LoadPicture(sTemp) 'This is where the error occurs.
Kill sTemp
End If
End With
Last edited by jeremy_ckw; Apr 8th, 2003 at 12:23 AM.
"If ignorance is bliss, that probably explain why I'm in a such a mess right now!!"
-
Apr 8th, 2003, 08:38 AM
#6
Addicted Member
The image path can only be set in the section format sub.
I assume from your code that the image is in section2 on the report.
Code:
'Double-click anywhere in section 2 to get to the format sub.
Private Sub Section2_Format(ByVal pFormattingInfo As Object)
Set crxPicObj.FormattedPicture = LoadPicture(App.Path & "\Images\TempPic.jpg"
)
end sub
Delete from your code
Code:
Set crxPicObj.FormattedPicture = LoadPicture(sTemp)
Add the following code to
-
Apr 9th, 2003, 02:26 AM
#7
Addicted Member
Thanks for you reply!
You are right, the image can only be set in the section event. I think I'm using a wrong way to do this.
How do you double click on the section? I just have a crviewer on a form, that's all. Clicking it is like clicking any other components. It doesn't show me the section.
Regards,
"If ignorance is bliss, that probably explain why I'm in a such a mess right now!!"
-
Apr 9th, 2003, 08:46 AM
#8
Addicted Member
The report viewer is used to display a report. You still need to add a report to your application.
From the main menu, select Project, Add Crystal Reports 8.5
If you have an existing report, you can import it from here.
This will create a report that will appear in the Designer section in the Project Window. Double click on that and a list of all designer objects will appear (ie your report). Double click on your report and it will open up like any other VB form. This is where you will double click on the picture to get to the format section.
Read the link I gave above, it will show you how to interact between the viewer and you report.
Hope this helps.
-
Apr 24th, 2003, 01:32 PM
#9
Junior Member
Originally posted by Ken Bradford
The report viewer is used to display a report. You still need to add a report to your application.
From the main menu, select Project, Add Crystal Reports 8.5
If you have an existing report, you can import it from here.
This will create a report that will appear in the Designer section in the Project Window. Double click on that and a list of all designer objects will appear (ie your report). Double click on your report and it will open up like any other VB form. This is where you will double click on the picture to get to the format section.
Read the link I gave above, it will show you how to interact between the viewer and you report.
Hope this helps.
Could you please tell me how to add Crystal report to project?
I went to the main menu and click "project", but there is no selection for adding Crystal report, only "data report", are you talking about that one?
please help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|