1.11M Members

How to pass value from a textbox into crystal reports

 
0
 

I'm completely clueless to this as I have never used crystal reports before. So I want to use a textbox to pass values into my crystal report so basically only those I inputted into my textbox will be read and be outputted into my crystal report.

Here is my code so far:

Dim report As New crystalreportloginfo
    Dim adapter As New SqlDataAdapter("select * from log_information where account_id='" & txtsearchaccountid.Text & "'", connection)
    Dim datatable As New DataTable
    adapter.Fill(datatable)

    report.SetDataSource(datatable)
    Login_Information_Report.viewerloginfo.ReportSource = report
    Login_Information_Report.viewerloginfo.RefreshReport()
 
0
 

Hope this will help you

Dim cryRpt As New ReportDocument


        CrystalReportViewer1.SelectionFormula = "{Product_Details.P_Id}= '" & Textbox1.Text & "'"
        cryRpt.Load("G:\Sales and inventory system\Product.rpt")
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
 
0
 

hi Iamkenny?
are you trying to load data from a database into a textbox then output it on a crystal report or you just want to output what you've type in the textbox?

 
0
 

I have given the way to insert through database to the report K-Dave to do you know how to insert data through textbox directly to crystal report.

 
0
 

I used this coding which had been in this forum sometime a back ,but i got error in 9th line as"Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))"

Dim cryRpt As New ReportDocument
        Dim report As New CrystalReport1

        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue
        crParameterDiscreteValue.Value = TextBox1.Text
        crParameterFieldDefinitions = report.DataDefinition.ParameterFields()
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("@Parameter")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article