Reputation: 3
I have a "Create Check form" with text boxes and a datetimepicker. In form1 (CreateCheckForm), the user will fill the text boxes Payee, Amount_in_Figure
, and date
which will be printed out after clicking the btnButton
right after filling those text boxes. Now, I want the text box values to be passed into my other form with crystal report so i can print it WITHOUT saving it yet to database, but whenever I click the button, nothing shows up in my crystal report. Just a blank page.. Below is my code:
This is the code behind the form with crystal report (form2):
Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
Dim Report1 As New CrystalReport1
Report1.SetParameterValue("amtinwords", frmCreateCheckURC.txtAmtInWords.Text)
CrystalReportViewer1.ReportSource = Report1
Report1.SetParameterValue("issuedate", frmCreateCheckURC.dtpDate.Text)
CrystalReportViewer1.ReportSource = Report1
Report1.SetParameterValue("?amtinfigure", frmCreateCheckURC.txtAmtInWords.Text)
CrystalReportViewer1.ReportSource = Report1
Report1.SetParameterValue("?payee", frmCreateCheckURC.txtAmtInWords.Text)
CrystalReportViewer1.ReportSource = Report1
End Sub
Parameter names are amtinwords,issuedate,amtinfigure,amtinwords,payee
Upvotes: 0
Views: 977
Reputation: 3
I was able to resolve my problem. The only problem is that I posted the code on the wrong place and form. The code should have been in btnButton
's .
Upvotes: 0
Reputation: 420
Try below code to pass the data from form1 to form2 and then try to pass data to crystal report with your code
Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sTitle As String
Dim sText As String
sTitle = TextBox1.Text
sText = TextBox2.Text
Dim frm As New Form2(sTitle, sText)
frm.Show()
End Sub
Form2
Public Sub New(ByVal sTitle As String, ByVal sText As String)
InitializeComponent()
Me.Text = sTitle
Me.Label1.Text = sText
End Sub
Upvotes: 2