Search code examples
vb.netcrystal-reportsms-access-2007

how to print textbox value in crystal report header section using vb.net?


i am having crystal report! on that i want to print entered value of textbox in crystal report my code is,

  Dim report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    Dim xs As String
    xs = salfdte2.Text
    Dim cmd1 As OleDbCommand = New OleDbCommand("SELECT * from product",con)
    myDA = New OleDbDataAdapter(cmd1)
    myDataSet = New DataSet()
    myDA.Fill(myDataSet, "product")
    report.Load(Application.StartupPath & "\saledtewserpt.rpt")
    report.SetParameterValue("fdte", xs)
     'the above line is my pproblem
    report.SetDataSource(myDataSet.Tables("outwardp"))
    saledtereport.CrystalReportViewer1.ReportSource = report
    saledtereport.ShowDialog()

it works well but during run time the report asks me to enter parameter value for fdte parameter! i dont want this prompt! how to solve this problem? thanks in advance developers.


Solution

  • I think you're required to set the parameters on the ReportViewer after setting ReportViewer.ReportSource.

    saledtereport.CrystalReportViewer1.ReportSource = report
    saledtereport.ParameterFieldInfo.Item("fdte").CurrentValues.Add(xs)
    

    On the other hand, if you're just trying to set the value of a textbox named myTextBox, you might be able to do something like

    Dim textBox As CrystalDecisions.CrystalReports.Engine.TextObject
    textBox = Report.ReportDefinition.ReportObjects.Item("myTextBox")
    textBox.Text = ws