I have a table there in SQL SERVER 2000 which has five fields[date income amount expense amount]. Now user wants to input first date & last date there in form to show records ok? To show record by one paraemeter was easy for me & I did it by following code. I mean I made one parameter & got one form with one text box & one button & one report viewer. Let me show you my code for button event what I used to show report by one parameter.
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("id")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
cryRpt.RecordSelectionFormula = "{Button1}= " & TextBox1.Text & ""
End Sub
But now I have created two parameter to show report.
Parameter : {asst.dt} >= {?fdt} and {asst.dt} <= {?ldt}
fdt(first date & ldt(last date)
I have a form with two text boxes & one button & one report viewer. When user will input first date there in the first text box & last date there in last text box & click on show button it will show records between two dates including first date & last date. As a result I have wrtie code for button event right? I am using my previous code which is
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 & "\CrystalReport1.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("id")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
cryRpt.RecordSelectionFormula = "{Button1}= " & TextBox1.Text & ""
End Sub
but it doesnt work. Because it works for one parameter. Now would you please tell me what should I change or add there in my button event code to do what I am trying to do? Is it clear? For example user will input 1-1-2010 there in first text box & 30-1-2010 there in last text box when he will click on show button it will show record between 1-1-2010 & 30-1-2010 including 1-1-2010 & 30-1-2010. I hope you can understand it now. Please help me to solve this problem. I hope you will explain it to me properly because I am just a beginner.