Hello,
Following is the code written to call a crystal report having records for branch 3 only:
Dim appl As New CRAXDRT.Application
Dim rpt As New CRAXDRT.Report
Dim dat As CRAXDRT.Database
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set rpt = appl.OpenReport(app.path & "\password.rpt", 1)
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "dsn=invdet"
rs.Open "select * from table1 where branch=3", cn, adOpenStatic, adLockPessimistic
Set dat = rpt.Database
dat.SetDataSource rs, 3, 1
CR.ReportSource = rpt
CR.ViewReport
Error:
The Report shows all the records from "table1". It resembles the same report when I run from Crystal Reports.
i.e. it is not reporting for the above recordset set.My changes are in Bold.
'Get rid of these
'Dim appl As New CRAXDRT.Application
'Dim rpt As New CRAXDRT.Report
'Dim dat As CRAXDRT.Database
Dim Report as CrystalReport1 'This is the dsr file that you create
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set rpt = appl.OpenReport(app.path & "\password.rpt", 1)
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "dsn=invdet"
rs.Open "select * from table1 where branch=3", cn, adOpenStatic, adLockPessimistic
Report.SetDataSource rs, 3, 1
'Make sure CR is the name of the CrystalViewer on your form
CR.ReportSource = Report
CR.ViewReport|||I do not know how to create the dsr file|||What version of Crystal Reports are you using?|||I am using version 8.5|||I'm using version 8.5 Developer Edition. When I installed it, it placed all the necessary dlls on my comuter for me.
To create a dsr file, All I have to do is click 'Project', 'Add Crystal Reports 8.5'. Then follow the directions to create a dsr file.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment