I have this problem where crystal report is prompting me to enter a value even though I already pass the value from textbox in the vb form.
This is how I create the parameter:
As you can see, I named the parameter NAME
.
And here is my code for passing the value from TextBox
to parameter NAME
in crystal report:
Private Sub indi_print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles indi_print.Click
Dim locatorReport As New report_viewer
Dim rptDoc As CrystalReports.Engine.ReportDocument
rptDoc = New indi_locatorReport 'indi_locatorReport is the Crystal Report
rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLegal
rptDoc.PrintOptions.ApplyPageMargins(New CrystalDecisions.Shared.PageMargins(200, 200, 100, 1500))
rptDoc.SetParameterValue("NAME", name_txtbox.Text)
locatorReport.crptViewer.ReportSource = rptDoc
locatorReport.ShowDialog()
End Sub
When i click the Print Button
this is the result:
As you can see Crystal Report prompt me to enter a name. How to fix this?
I already solved the problem. The problem is whenever the form report_viewer
loads, it refreshes the crystal report. It has the Me.crptViewer.RefreshReport()
code. I did not notice this because the crystal report viewer created this code.