Click here to Skip to main content
16,012,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can show information by specific ID there in crystal report by following code.

Code:
VB
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 I got a problem. I have a table where it has three fields. One for date one for income & another for expense. To show it I have a form two text boxes & one crystal report viewer.
My problem is that to show a record of specific date is easy & I can do it by previous code. But according to user he wants to input starting date & end date to see records. So what should I do now?

Can you please help me to do it? For example he needs to input starting date 1-1-2010 & end date 30-1-2010 & he wants to see all reports of January month including 1-1-2010 & 30-1-2010.

I need help please help me.
Posted
Updated 20-Jul-10 1:20am
v2
Comments
Sandeep Mewara 20-Jul-10 7:21am    
Use PRE tags to format code part. It makes the question readable.

1 solution

This is a very basic of crystal report

In time of designing your report create two parameters for starting and end date and add a between clause in your query. Pass those two parameter values from your application. Alternatively you can use a range parameter.

Try some study on crystal report before you start.
 
Share this answer
 
v2

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