Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a crystal report and a subreport in vb.net
I want to Filter the records to be displayed in the sub report
by typing the name in the textbox and after clicking a button
it will show all records that have the same name in the textbox.

I tried some code below but this error pops up
Crystal Report Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))


What I have tried:

Dim cryRpt As New ReportDocument
      cryRpt.Load("C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Profile\Profile\CrystalReport1.rpt")

      Dim crParameterFieldDefinitions As ParameterFieldDefinitions
      Dim crParameterFieldDefinition As ParameterFieldDefinition
      Dim crParameterValues As New ParameterValues
      Dim crParameterDiscreteValue As New ParameterDiscreteValue

      crParameterDiscreteValue.Value = ComboBox1.Text
      crParameterFieldDefinitions = _
      cryRpt.DataDefinition.ParameterFields
      crParameterFieldDefinition = _
 crParameterFieldDefinitions.Item("Name")
      crParameterValues = crParameterFieldDefinition.CurrentValues

      crParameterValues.Clear()
      crParameterValues.Add(crParameterDiscreteValue)
      crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

      CrystalReportViewer1.ReportSource = cryRpt
      CrystalReportViewer1.Refresh()
Posted
Updated 18-Jul-22 23:37pm

You haven't told us which line the error is thrown from. At a guess, it's the crParameterFieldDefinitions.Item("Name") line, which means your report doesn't contain a parameter with that name.

You need to examine your report to find out what the correct parameter name is, and use that instead.
 
Share this answer
 
I don't know if this is a solution

I can't find the problem in the code, i checked my parameters,columns. its correct but it says the "cant find the column "name" ".

so I used parameters fields instead

so before loading the crystal report

I added a parameter for the main report, they can input the name they wanted to be displayed
and linked the sub report in the parameter field of the main report

now it displays the name in the main report at the same time in the sub report.
thanks for answering anyway.
 
Share this answer
 
v2
there might be the error in backend(SQL or any) or sub-report(if exists)
 
Share this answer
 

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