How to pass two parameter fields in crystal report

2019-09-06 16:47发布

I have a table name logs that holds the accomplishments log of the employees in a particular organization

    ID
    User_ID
    Logs
    StartDate
    StartTime
    FinishedDate
    FinishedTime

I want only to print based on two user inputs. The User_ID and FinishedDate. How to achieve it using Crystal Report?

1条回答
姐就是有狂的资本
2楼-- · 2019-09-06 17:23

This assumes you already have a report displaying data from that table (and you don't already have parameters in your report):

  1. Create the parameters user_Id and FinishedDate in your crystal report - right click parameter fields, and add new
  2. Click the Report menu, then "Select Expert"
  3. Pick the field from your data base, and choose whether you want it to be equal to you parameters
  4. You can customise the selection criteria in the formula editor

To apply these parameters from your VB application after data binding, you need to call the SetParameterValue method on the report object as follows:

report.SetParameterValue("User_Id", 1256)
report.SetParameterValue("FinishedDate", date)

Edit

You'll need to research loading data into your report in more detail. Your question was how to pass parameters to crystal from VB.net. Below is a brief run through:

' Create a report document - pointing to your .rpt file
report = new ReportClass()
report.FileName = fileName
' Assign the report object to your viewer
ReportViewer.ReportSource = report
' perform any database logon
report.SetDatabaseLogon(...credentials...)
查看更多
登录 后发表回答