0
votes

I am working on the crystal report and I am having some issues with selection formula as I am not able to use variable in the below code. However if I, mention the string directly then formula is working

Code not working: Dim tb As String= "104" CrystalReport. SelectionFormula= "{table1.tableno}= tb"

Above code is not working and giving a message, string field required, however I have already define my variable 'tb' as string.

Below code is working without using variable: CrystalReport. SelectionFormula= "{table1.tableno}= '104' "

Any help would be greatly appreciated!

2

2 Answers

0
votes

You need to use parameter fields to pass values from your code to crystal reports, check this link it will show you exactly how to do it ..

edited: you would do that like so.. dtt is a datatable here..

CrystalReport1.SetDataSource(dtt)
CrystalReport1.SetParameterValue("param", TextBox1.Text)
CrystalReportViewer1.ReportSource = CrystalReport1
CrystalReportViewer1.Refresh()
0
votes

I think your code should be:

Dim tb As String= "104"
CrystalReport.SelectionFormula= "{table1.tableno}='" + tb +"'"