Hey guys!

I need a little help with Crystal Reports!The Report keeps repeating the details.I tried to group it by the reference number but it keeps displaying it four times!Also how can I order the report by reference number?Please help me its the last thing for me to finish my software!Here's my code:

Dim crptdoc As New CrystalReport1
        Dim mystr As String
        Dim myDS As New DataSet1

        crptdoc.Load("C:\Users\ACP\Documents\Visual Studio 2005\Projects\Sistema ManoObras\SistemaManoObras\SistemaManoObras")
        crptdoc.SetDataSource(myDS.Tables("Payroll"))

        mystr = "{Employees.EmployeeID} = " & Val(Form1.TxtEmpID.Text) & "and {Payroll.PayrollID} = " & Val(Form1.TxtPayrollID.Text) & ""

 CrystalReportViewer1.SelectionFormula = mystr
        CrystalReportViewer1.ReportSource = crptdoc

Recommended Answers

All 4 Replies

please can you show your query , so we can help you .
and please check these links
http://www.crystalkeen.com/articles/crystalreports/groupexpert.htmhttp://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=4728

Regards

Thanx for the reply!The code that I posted is in the CrystalReportViewer formload..that's the only code I'm working with!Sorry if this isn't enough but I'm new to Crystal Reports and basically this is the only code that worked for me!The code is working fine its just that's displaying fields 4 times instead of one!I don't know if I can filter the report using a SQL statement string or any other way.Any suggestions is welcomed!

*Note:I'm a newbie!

THANX

when you create a report then you used a query or tables in it , in above code you are just calling that report . well please post some snaps of your report here ,

Regards

Hey guys!

I need a little help with Crystal Reports!The Report keeps repeating the details.I tried to group it by the reference number but it keeps displaying it four times!Also how can I order the report by reference number?Please help me its the last thing for me to finish my software!Here's my code:

Dim crptdoc As New CrystalReport1
        Dim mystr As String
        Dim myDS As New DataSet1

        crptdoc.Load("C:\Users\ACP\Documents\Visual Studio 2005\Projects\Sistema ManoObras\SistemaManoObras\SistemaManoObras")
        crptdoc.SetDataSource(myDS.Tables("Payroll"))

        mystr = "{Employees.EmployeeID} = " & Val(Form1.TxtEmpID.Text) & "and {Payroll.PayrollID} = " & Val(Form1.TxtPayrollID.Text) & ""
       
 CrystalReportViewer1.SelectionFormula = mystr
        CrystalReportViewer1.ReportSource = crptdoc

[icode]
[/QUOTE] 

Try out this


[code]

[code]

'Import
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

'Form Load event
      Dim cryRpt As New ReportDocument
        cryRpt.Load(Application.StartupPath & "\Reports\CRBill.rpt")'ur crystal report path goes here

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

        crParameterDiscreteValue.Value = frmMain.dtpFromBill.Value.ToString("yyyy-MM-dd")
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("fromdate") 'the red one is the paramenter name I have created
        crParameterValues = crParameterFieldDefinition.CurrentValues

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


        crParameterDiscreteValue.Value = frmMain.dtpToBill.Value.ToString("yyyy-MM-dd")
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("todate")'the red one is the paramenter name I have created

        crParameterValues = crParameterFieldDefinition.CurrentValues

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

        crParameterDiscreteValue.Value = frmMain.txtPatName.Text
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("patname")'the red one is the paramenter name I have created

        crParameterValues = crParameterFieldDefinition.CurrentValues

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

        crvBill.ReportSource = cryRpt
        crvBill.Refresh()

[/code]
u can set the selection formula in the crystal report itself....

First create the parameters that u need and then right click on the cystal report for report-> selection formula->record

mention the criteria in the editor...

'code I had written in the selection editor... the one with ? in fromt are my parameter names

{Appointment.PatientID} = {patientreg.patientid} and {patientreg.patientname} = {?patname} and {Appointment.DoctorID} = {DoctorRegister.DoctorID} and {Appointment.TreatmentID} = {TreatmentMaster.TreatID}  and {Appointment.ApptDate} in {?fromdate} to {?todate}

hope this helps u.... :)

commented: unnecessary code,with out knowing the prob. -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.