Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know how to show record by one parameter. But what should I write there in my button event to show record by two parameter? I have created two parameter & I have written it {asst.dt}= {?fdt} and {asst.dt} = {?ldt} there in formula workshop. Now I got a problem! I have a button there in my form with two text boxes with one report viewer. Before I had written following code. So what should I write now? Please help me.

Code(I have used it to show report by one parameter where form had one text box one button & one report viewer).

VB
Code : Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form6
Inherits System.Windows.Forms.Form


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim cryRpt As New ReportDocument
cryRpt.Load(Application.StartupPath \CrystalReport5.rpt")
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()

Dim cryRpt As New ReportDocument
cryRpt.Load(Application.StartupPath \CrystalReport5.rpt")

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

crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item
crParameterValues = crParameterFieldDefinition.CurrentValues

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

CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
cryRpt.RecordSelectionFormula = {Button1}= TextBox1.Text
End Sub
Posted

1 solution

Instead of passing a parameter to crystal report, use a query in your code,

and fill the Datatable/DataSet. Set this Datasource to the ReportViewer

It may reduce your code complxity, and can solve your problem
 
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