Skip to Content

Error when passing text values to Crystal Report Formula field from VB.Net

I am trying to pass some text to a formula field in a Crystal Report. Formula field name is "txtShopName". shopName is a variable and it has the value of "TORCH-MINIMALL". I use VB.net to view the report and pass the parameter value as follows. However, I get an error when trying to view the report.(Image attached)

What could be the reason?. Is there any specific way which I have to create the formula field in the report?.

                Dim crepBill As New repBill
                crepBill.SetDatabaseLogon("sa", dbPwd)
                crepBill.DataDefinition.FormulaFields.Item("txtShopName").Text = shopName
                crepBill.RecordSelectionFormula = "{TB_SALES.bill_no} ='" & "B000002" & "'"
                CrystalReportViewer1.ReportSource = crepBill
                CrystalReportViewer1.Zoom(100)
                CrystalReportViewer1.Refresh()
                CrystalReportViewer1.RefreshReport()

err.png (7.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 17 at 05:50 PM

    Your single/double quotes don't match:

    "{TB_SALES.bill_no} ='" & "B000002" & "'"

    Use single quotes inside and wrap the whole thing in double quotes.

    Something like this

    "{TB_SALES.bill_no} = 'B000002'"

    Don

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.