07/03/2012

How to remove " A number Required here" error from crystal report?

After coding my data entry forms and inquiry forms I was in final lap of my software and I was designing crystal report but when I run  my crystal report I got an error message" A number required here"  I know that  my data field on which I am filtering the data in crystal report is a number type of data so this error can be removed by changing the data type in data table but as I wan in final lap of my program so if I change my data type in data table then my other forms will also not function properly. the code which give error was as
under:

Dim rep As CrystalDecisions.CrystalReports.Engine.ReportDocument
        rep = New ReportIndividualDeployment
        If RbtAll.Checked Then
            If TxtPISNo.Text = "" Then
                MsgBox("Please Enter a PIS No")
                TxtPISNo.Focus()
                Exit Sub
            End If
            Dim ds As New DsReportLeave 'The dataset that you have created in XML
 DaIndDeployment.Fill(ds, "Deployment")
 rep.SetDataSource(ds)
 FrmReportViewer.CRV.SelectionFormula = {Deployment.PISNumber}="’ &(TxtPISNo.Text)_ & "’"
            rep.SummaryInfo.ReportTitle = "DEPLOYMENT DETAIL"
            FrmReportViewer.CRV.ReportSource = rep
            FrmReportViewer.ShowDialog()
            FrmReportViewer.Dispose()
            Me.Close()
        End If
this one minor error has taken my two hours and after lots of trial and run in syntax, when the solution syntax I got which is very simple, I just removed the two single quote (') which I have used in my syntax and then every thing started working fine. so  to filter a number data type in crystal report the right code is as under

Dim rep As CrystalDecisions.CrystalReports.Engine.ReportDocument
        rep = New ReportIndividualDeployment
        If RbtAll.Checked Then
            If TxtPISNo.Text = "" Then
                MsgBox("Please Enter a PIS No")
                TxtPISNo.Focus()
                Exit Sub
            End If
            Dim ds As New DsReportLeave 'The dataset that you have created in XML
 DaIndDeployment.Fill(ds, "Deployment")
 rep.SetDataSource(ds)
 FrmReportViewer.CRV.SelectionFormula = {Deployment.PISNumber}=" &(TxtPISNo.Text) & ""
            rep.SummaryInfo.ReportTitle = "DEPLOYMENT DETAIL"
            FrmReportViewer.CRV.ReportSource = rep
            FrmReportViewer.ShowDialog()
            FrmReportViewer.Dispose()
            Me.Close()
        End If

Happy Coding



















No comments:

Post a Comment

What & How