By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,558 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,558 IT Pros & Developers. It's quick & easy.

How to pass image path to crystal report 8 through VB6

P: 5
I have stored image address in the database (Ms-Access).
I wanted to pass run time this image path to crystal report to display the image in report.
I am using VB6, Ms-Access and Crystal report 8.
How to do it?
Nov 3 '06 #1
Share this Question
Share on Google+
2 Replies


sashi
Expert 100+
P: 1,754
I have stored image address in the database (Ms-Access).
I wanted to pass run time this image path to crystal report to display the image in report.
I am using VB6, Ms-Access and Crystal report 8.
How to do it?
Hi there,

Will only be able to help u unless u show us your code segment. Think abt it, hope to hear from u soon.
Nov 3 '06 #2

P: 5
Hi there,

Will only be able to help u unless u show us your code segment. Think abt it, hope to hear from u soon.

Hi Sashi,

I am working on large-scale project entitled as MIS (Marketing information System). As I told you that I am using Vb 6 as front end, Ms Access as back end and Crystal report 8 as reporting tool.

1) In the project it is required to save dealerís photo, and it should be shown in individual dealerís detail report, which will include his/her image. I had taken Common dialog box control to select image and display it in image control.

2) The size of database is very large then, which will be useful from the following?

i. to store image to database?
(But it makes database larger in size which leads to slower access)

ii. Saving path of image in database

To keep database safe I want to try the second option first. Instead coding directly into project, I want test the logic into small program first. As we know that by use of common dialog control we can select image and show it in image control. Also same path can be stored in database. Also we can retrieve the path from database and show it image control.

Until here all things are ok. Now problem is that how to show the image in crystal report. Usually we pass the fields directly to crystal report by sending sql-query to it.

Here is some code part from the project. I am using crystal report viewer control to show the reports.

Following is report module:

Option Explicit

Public Function SET_REPORT_OBJECT(strReportName) As Report

On Error GoTo ErrTrap:

Dim Report_App_obj As Object
Dim Report_Obj As Report

Set Report_App_obj = Nothing
Set Report_App_obj = CreateObject("CrystalRuntime.Application.8")
Report_App_obj.LogOnServer "P2SODBC.DLL", "esm", "", "admin", "cb10esm"
Set Report_Obj = Report_App_obj.OpenReport(App.Path & strReportName, crOpenReportByTempCopy)
Set SET_REPORT_OBJECT = Report_Obj

Exit Function
ErrTrap:
Set SET_REPORT_OBJECT = Nothing
Exit Function
End Function

Following is code to pass the Query string to the report:

cmdAddressLabelPrinting.Enabled = False

On Error GoTo ErrTran
Dim rptName As String

Dim strSQL As String
Dim strQry As String

If chkCourior.Value = 1 Then
rptName = "\rptCouriorLabels2.rpt"
chkCourior.Value = 0
Else
rptName = "\rptLabels.rpt"
End If

Dim StrFilterString As String

'''Code For Manual Selection of Parties
StrFilterString = rsParty.Filter
frmListParties.PrintType = "New"
frmListParties.Show vbModal
If frmListParties.PrintType <> "Done" Then
MsgBox "Cannot continue Printing." & vbCrLf & "No Parties To Print!", vbExclamation + vbOKOnly
Screen.MousePointer = vbNormal
If StrFilterString <> "0" Then
rsParty.Filter = StrFilterString
Else
rsParty.Filter = adFilterNone
End If
rsParty.Requery
cmdAddressLabelPrinting.Enabled = True
Exit Sub
End If
Screen.MousePointer = vbHourglass
'''Code For Manual Selection of Parties

If rsParty.RecordCount = 0 Then Exit Sub

strQry = " Where partyCode in ("

rsParty.MoveFirst
While Not rsParty.EOF
If strQry <> " Where partyCode in (" Then strQry = strQry & ","
strQry = strQry & rsParty.Fields("partyCode")
rsParty.MoveNext
Wend
strQry = strQry & ")"

strQry = strQry & "order by priority ASC "

Set mReport = SET_REPORT_OBJECT(rptName)
strSQL = "SELECT partyName,priority,partyAddress, areaName, CityName, pinCode, stateName, partyPhone1, directorName " & _
"From qryAddressLabels " ' & "ORDER BY priority ASC "

If strQry <> "" Then
strSQL = strSQL & " " & strQry

End If

If mReport Is Nothing Then Exit Sub
mReport.DiscardSavedData

'mReport.ParameterFields(1).ClearCurrentValueAndRa nge
'mReport.ParameterFields(1).AddCurrentValue Str((RegistrationFeeAmt + SalesKitAmount))
mReport.SQLQueryString = ""
mReport.SQLQueryString = strSQL
frmReport.CRViewer1.ReportSource = mReport
frmReport.CRViewer1.ViewReport
Screen.MousePointer = vbNormal
frmReport.Show vbModal
Set mReport = Nothing

If StrFilterString <> "0" Then
rsParty.Filter = StrFilterString
Else
rsParty.Filter = adFilterNone
End If
rsParty.Requery
cmdAddressLabelPrinting.Enabled = True


If you require more details, please let me know. I will make it available.

Regards,

Kiran.
Nov 4 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.