Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters to a crystal report 1

Status
Not open for further replies.

egstatus

Programmer
Apr 14, 2005
143
US
Hi all, I don't know if this is the right forum to post this on.
I'll give it a try.

I am using vb.net 2008. I have a form which uses a a query to populate. The form uses UserID=Text1.text and InputDate between Text2.text and Text3.text and passes those values to the query.

I've been asked to create a crystal report and print the result of the form.

My question is:
How do I pass the parameters to crytal reports?

I found some info on how to pass a single parameter, I have not been able to find anything on the Between dates field or when passing multiple parameter values.

Any help would be greatly appreciated.

Thanks

EG


 
Thanks PRPhx.
I had already seen both of this links, and none of them work correclty. I have 3 parameters that I am passing. It works with 2 parameters but whenever I have a 3rd one it changes the value of the first 2 the the value of the 3rd one. And still promps me to enter the param values.

I'll keep searching.

Thanks

EG
 

Could you show the code you are using to pass the parameters?


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Hi,
I have 3 parameters declared, they are employeeName, fromDate, and toDate.

After I assing the first param to employeeName, and I checkt the value, it has the right value. However after I assing the second parameter [fromDate], it changes the value of employeeName to whatever value the second parameter has.

Here is the code
Code:
   'Dim cryRpt As New ReportDocument
        Dim cryRpt As NovelLoginReport = New NovelLoginReport
        'cryRpt.Load("C:\VB2008\ImportingDataToSql\ImportindDataToSql\NovelLoginReport.rpt")

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldLocation As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue

        Try
            crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields

            'The Employee Name Param
            crParameterFieldLocation = crParameterFieldDefinitions.Item("employeeName")
            crParameterValues = crParameterFieldLocation.CurrentValues
            crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
            crParameterDiscreteValue.Value = frmNovellLogingRecords.strEmployeeName
            crParameterValues.Add(crParameterDiscreteValue)
            crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

            ''The From Date Param
            crParameterFieldLocation = crParameterFieldDefinitions.Item("fromDate")
            crParameterValues = crParameterFieldLocation.CurrentValues
            crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
            crParameterDiscreteValue.Value = CDate(frmNovellLogingRecords.lblFrom.Text)
            crParameterValues.Add(crParameterDiscreteValue)
            crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

            ''The To Date Param
            crParameterFieldLocation = crParameterFieldDefinitions.Item("toDate")
            crParameterValues = crParameterFieldLocation.CurrentValues
            crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
            crParameterDiscreteValue.Value = CDate(frmNovellLogingRecords.lblTo.Text)
            crParameterValues.Add(crParameterDiscreteValue)
            crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

            cryRpt.SetDataSource(frmNovellLogingRecords.StatusDataNovelLoginsDataSet)

            With Me.crNovelLoginViewer
                .DisplayGroupTree = False
                .ShowTextSearchButton = False
                .ShowGroupTreeButton = False
                .ReportSource = cryRpt
                crNovelLoginViewer.RefreshReport()
            End With
        Catch ex As Exception

        End Try
 
I am sorry, I also forgot to mention that it still promps me to enter each parameter.

Thansk
 

Hmmm...when I pass parameters to my Crystal Reports, I just do this:

Dim rBudget As New rptBudgetDetail

rBudget.SetDataSource(Module1.dtBudget)

rBudget.SetParameterValue("AY", Module1.AY)
rBudget.SetParameterValue("Group", Module1.BudGroup)
rBudget.SetParameterValue("EndDate", Module1.EndDate)
rBudget.SetParameterValue("DBName", Module1.DBName)


The first parameter in the SetParameterValue method is the parameter's name, and the second is the value to assign to that report parameter. Give it a shot and let us know what happens.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks jebenson,
I tryed your sugestion, and I still can't get it to work.
I have created thar parameter fields with discrete values.

here is the code:
Code:
       Dim cryRpt As New ReportDocument
       cryRpt.Load("C:\VB2008\ImportingDataToSql\ImportindDataToSql\NovelLoginReport.rpt")
 
        Try
            cryRpt.SetDataSource(frmNovellLogingRecords.StatusDataNovelLoginsDataSet)
            cryRpt.SetParameterValue("employeeName", frmNovellLogingRecords.strEmployeeName)
            cryRpt.SetParameterValue("fromDate", CDate(frmNovellLogingRecords.lblFrom.Text))
            cryRpt.SetParameterValue("toDate", CDate(frmNovellLogingRecords.lblTo.Text))


            With Me.crNovelLoginViewer
                .DisplayGroupTree = False
                .ShowTextSearchButton = False
                .ShowGroupTreeButton = False
                .ReportSource = cryRpt
                crNovelLoginViewer.RefreshReport()
            End With
        Catch ex As Exception

        End Try
It stills prompt me to enter the param values. Why?
Do you see anything wrong here?
Thanks
 

Ok, I think it may be this line:

crNovelLoginViewer.RefreshReport()

Try using this instead:

crNovelLoginViewer.Show()

RefreshReport reloads all of the data, and clears out the parameters in the process. So the report viewer asks you for new parameter values.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks jebenson, that line did the trick.

I apreciate the help given.

keepup the good work.

EG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top