|
-
Nov 21st, 2008, 12:28 AM
#1
Thread Starter
Junior Member
how to use parameter in crystal report
I Wish to pass parameter to Crystal Report. I have Access data base one table named student. I with to select range of data's from that table field named "rno"
i am using visual basic 6
I used following code to view crystal report
================================================
Set rs = New ADODB.Recordset
modConnection.opendb
rs.Open "select * from STUDENT_M order by rno", cn, adOpenStatic, adLockPessimistic
Report.Database.SetDataSource rs
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
==========================================
I am new to crystal report. please guide me how to use parameter in crystal report.
a.Senthil kumar.
-
Dec 2nd, 2008, 03:59 AM
#2
Member
Re: how to use parameter in crystal report
I don't use VB6 but I do something like this.
you can add as many parameters as are needed for the report.
Code:
If dtFromDate <> Nothing And dtToDate <> Nothing Then
strSelectField = "@dtFromDate=" & dtFromDate.ToString
strSelectField &= "&@dtToDate=" & dtToDate.ToString
End If
in your standard selection of the report
Code:
If intCounter1 > 0 And Trim(param) <> "" Then
strParValPair = param.Split("&")
For index = 0 To UBound(strParValPair)
If InStr(strParValPair(index), "=") > 0 Then
strVal = strParValPair(index).Split("=")
paraValue.Value = strVal(1)
currValue = _
objReport.DataDefinition.ParameterFields(strVal(0)).CurrentValues
currValue.Add(paraValue)
objReport.DataDefinition.ParameterFields(strVal(0)).ApplyCurrentValues(currValue)
End If
Next
End If
Then I add Parameters @dtFromDate and @dtToDate in your report.
you can use them in the select expert
Code:
{MediaDetails.PurchaseDate} in {?@dtFromDate} to {?@dtToDate}
Thanks
___________________________________
Using VB 2005
-
Dec 2nd, 2008, 04:50 AM
#3
Lively Member
Re: how to use parameter in crystal report
First, add a paramater to your report ...
Code:
Dim crRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim crParHeader As New CrystalDecisions.Shared.ParameterDiscreteValue
crRep.Load(Application.StartupPath & "/Report/" & xReport & ".rpt")
crParHeader.Value = xReportname
crRep.ParameterFields("Header").CurrentValues.Add(crParHeader)
' Display or Print
If xOption = "Display" Then
CrystalReportViewer.ReportSource = crRep
Else
crRep.PrintToPrinter(1, True, 0, 0)
End If
-
Jan 3rd, 2010, 10:40 AM
#4
New Member
Re: how to use parameter in crystal report
 Originally Posted by sigiK
First, add a paramater to your report ...
Code:
Dim crRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim crParHeader As New CrystalDecisions.Shared.ParameterDiscreteValue
crRep.Load(Application.StartupPath & "/Report/" & xReport & ".rpt")
crParHeader.Value = xReportname
crRep.ParameterFields("Header").CurrentValues.Add(crParHeader)
' Display or Print
If xOption = "Display" Then
CrystalReportViewer.ReportSource = crRep
Else
crRep.PrintToPrinter(1, True, 0, 0)
End If
At:
Code:
crRep.ParameterFields("Header").CurrentValues.Add(crParHeader)
NullReferenceException exception is thrown.
-
Jan 10th, 2010, 07:36 AM
#5
Lively Member
Re: how to use parameter in crystal report
did you add a parameter "Header" to your report ?
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
|