korsario said:
Hi. Someone could help me. Im trying to program a crystal report, but it shouold receive a data range (ex. 2004-03-01 and 2004-03-31). My problem is the reports shows all the rows in the table. In other words, how can I include the clause "Where idService=213" or "where date between=..."
Thank you very much.
I create 2 parameters in my Crystal Report and create a Record Formula using the parameters.
Record Forumla:
{tblHistory.DateEntered} >= {?pFromDate} and {tblHistory.DateEntered} <= {?pToDate}
I then pass the date range from vb to crystal using the following code:
Dim pfs As New CrystalDecisions.Shared.ParameterFields
Dim pf As CrystalDecisions.Shared.ParameterField
Dim pfDiscrete As CrystalDecisions.Shared.ParameterDiscreteValue
Add and set the FromDate
pf = New CrystalDecisions.Shared.ParameterField
pf.ParameterFieldName = "pFromDate"
pfDiscrete = New CrystalDecisions.Shared.ParameterDiscreteValue
pfDiscrete.Value = DateValue(txtFromDate.Text)
pf.CurrentValues.Add(pfDiscrete)
pfs.Add(pf)
Add and set the ToDate
pf = New CrystalDecisions.Shared.ParameterField
pf.ParameterFieldName = "pToDate"
pfDiscrete = New CrystalDecisions.Shared.ParameterDiscreteValue
pfDiscrete.Value = DateValue(txtToDate.Text)
pf.CurrentValues.Add(pfDiscrete)
pfs.Add(pf)
Assign the parameter collection to the viewer
CrystalReportViewer.ParameterFieldInfo = pfs
CrystalReportViewer.ReportSource = rptHistory
CrystalReportViewer.Zoom(1)
You can also use the parameters in the report heading if necessary.
Hope this helps.