1,105,581 Community Members

How to pass value from a textbox into crystal reports

Member Avatar
Iamkenny
Newbie Poster
6 posts since May 2012
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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()
Member Avatar
Dili1234
Junior Poster
169 posts since Aug 2012
Reputation Points: -2 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 3 [?]
 
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()
Member Avatar
K-Dave
Newbie Poster
20 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
Dili1234
Junior Poster
169 posts since Aug 2012
Reputation Points: -2 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 3 [?]
 
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.

Member Avatar
Dili1234
Junior Poster
169 posts since Aug 2012
Reputation Points: -2 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 3 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article