Dear All,

I am designing a crystal report in VB.NET

I have designed a crystal report i want to pass parameter from a textbox but when i pass parameter or without passing parameter run the report it pulls all the records from the database please help my code is as follows:

With Form12
            If TextBox9.Text = "" Then
                MsgBox("Please select a product to print.", MsgBoxStyle.Critical)

                Exit Sub
                .strReport = "Filter"
                .strWhere = "{PlotNo.Hiring} = """ & TextBox9.Text & """"
            End If
            Form12.ShowDialog()
        End With
Public strWhere As String
    Public strReport As String
    Private mReport As ReportDocument
    Private Sub Form12_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim pvCollection As New CrystalDecisions.Shared.ParameterValues
        Dim pdvBusName As New CrystalDecisions.Shared.ParameterDiscreteValue
        Dim pdvBusAddress As New CrystalDecisions.Shared.ParameterDiscreteValue
        Dim pdvContactInfo As New CrystalDecisions.Shared.ParameterDiscreteValue
        mReport = New ReportDocument()
        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

        mReport.Load(Application.StartupPath & "\HIR.rpt")

        mReport.RecordSelectionFormula = strWhere

        For Each tbCurrent In mReport.Database.Tables
            tliCurrent = tbCurrent.LogOnInfo
            With tliCurrent.ConnectionInfo
                .ServerName = Application.StartupPath & "\Payment.mdb"
                .UserID = ""
                .Password = ""
                .DatabaseName = Application.StartupPath & "\Payment.mdb"
            End With
            tbCurrent.ApplyLogOnInfo(tliCurrent)
        Next tbCurrent

        CrystalReportViewer1.ReportSource = mReport

You probably marked this thread as solved by mistake.
If that is so, then might I suggest a small change in the first snippet.
On line 7, do the following change:

'Your code
.strWhere = "{PlotNo.Hiring} = """ & TextBox9.Text & """"

'Remove the soft brackets and change it to this
.strWhere = "PlotNo.Hiring = '" & TextBox9.Text & "'"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.