Click here to Skip to main content
15,444,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In crystal report,
I have create a sub report.
linking that sub report with A field 'RecNo'
but run time it shows Dialog box

1. Enter Discrete value for Pm-Table.RecNo

2. This field name is not known.. error in formula record selection {Table.RecNo}={?Pm-Table.RecNo}. this field name is not known.

please suggest a way for solving this issue,
thanks in advance
Updated 4-Oct-12 20:00pm

1 solution

issue is solved, hope it will useful to them who are suffering with the same problem.

I have 2 sub reports accessing them from code using index 0 & 1 [for assign datasource runtime]. Index of subreports were inverted, so that datasource assignment was going wrong that's why in link parameter it was unable to find 'RecNo' because in that table there was not such field.

in practice prefer accessing subreport from code using name instead of index
when you will select subreport and see it's property[F4] there is a Name property it will give you name of subreport.

Dim orpt As New ReportDocument
Dim a = System.Reflection.Assembly.GetExecutingAssembly.Location
a = a.Substring(0, a.IndexOf("\bin\"))
dt.WriteXmlSchema(a & "\Reports\Receipt.xml")

Dim HeaderDT As DataTable
HeaderDT = DBGetData("select ...")
HeaderDT.WriteXmlSchema(a & "\Reports\HeaderRpt.xml")

orpt.Load(a & "\Reports\Receipt.rpt")
orpt.Subreports("HeaderRpt.rpt").SetDataSource(HeaderDT) 'index 1 accessed using 0 that was mistake
CrystalReportViewer1.ReportSource = orpt

Happy Coding!
Share this answer
thatraja 3-Jan-14 2:29am    
Aarti Meswania 3-Jan-14 3:09am    
Thank you! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900