I’m developing a windows forms application using VB.NET. I’m currently working on DataReport (by Microsoft, not Crystal). Everything works fine when using DataSet as DataSource. But I have a question on how am I going to put data to my DataReport from a user input? Preferably when the user is on the act of printing(clicking the print button in the ReportViewer), a Form will pop-up and ask him for input. That input I’m talking about is random names of people, and we don’t have to track their names so there’s no reason to put it on the database.
Here’s my simple setup:
-
MainForm.vb (Form)
- MyReportViewer (ReportViewer)
-
MyReport.rdlc (DataReport)
-
InputForm (Form)
- MyInputBox (TextBox)
If it is impossible to do it on the act of printing. Maybe on the MainForm_Load event or before the generation of report can do.
I’ve searched the net for an hour but I’m out of luck.
I’ve found the answer, it’s called ReportParameters.
Here’s how to set it:
On the DataReport(.rdlc), we have to add a
ReportParameters(Menu>Report>Report Parameters). The same name (OneParameter) should be used to avoid error. We can now use the parameter in our textbox, just put=Parameters!OneParameter.Valueand we’re done!Note: We have to set the report parameters before rendering the report. If we cannot avoid that, refresh the report after adding parameters so it will be updated: