cancel
Showing results for 
Search instead for 
Did you mean: 

Data did not show according to filter when first time loading CR

Former Member
0 Kudos

Hi,

Recently i just upgrade to Visual 2010 and converted crystal report to CR13 from my VS2005 projects.

But after converted i find out there is an error when first time loading report in my application.

The error was the data display did not according to filter and it showed all data instead.

The weird part is when i closed and reload again then it show data correctly.

May i know what is the problem? Is there any setting we need to do after converted to CR13?

Hope you can help me and provide some guides to me.

Thanks.

Regards

Susan Low

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Moved to .NET SDK forum.

Try adding a report.Refresh to the viewer.

Are you using a report with saved data?

Don

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Don,

Thanks for reply.

Ya, i already called report.refresh in viewer but still same.

Even i not using report with saved data also same problem.

If i closed and reprint again then only show the correct data. This only happen after my project converted to VS2010 and CR13.

Below is my sample codes, hope you can check for me if i did wrong in coding.


Private Sub btnPrintInvoice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintInvoice.Click
        If Me.cboInvFormat.Text.Trim.Length = 0 Then
            MsgBox("Please select Invoice Format for Printing.", MsgBoxStyle.Exclamation, "Print Invoice/Cash Bills")
            Exit Sub
        End If
        Me.getRF()
        If Me.c1txtrec.Value.ToString.Trim.Length > 0 And Me.chkReprint.Checked = False Then
            If Me.cboInvFormat.Text.Trim = "Standard" Then
                viewer.nameRpt = "Invoice"
            Else
                viewer.nameRpt = "Invoice2"
            End If
            viewer.ShowDialog()
        ElseIf Me.C1cboInvoice.Text.Trim.Length > 0 And Me.chkReprint.Checked = True Then
            If Me.cboInvFormat.Text.Trim = "Standard" Then
                viewer.nameRpt = "Invoice"
            Else
                viewer.nameRpt = "Invoice2"
            End If
            viewer.ShowDialog()
        Else
            MsgBox("Invoice No/Cash Sales cannot be blank.", MsgBoxStyle.Exclamation, "Print Invoice/Cash Sales")
        End If
    End Sub

Below is my coding in viewer form.

Dim report1 As New ReportDocument
Public nameRpt As String

Private Sub viewer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        assignreport()
        Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
        Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo

        For Each myTable In report1.Database.Tables
            myLogin = myTable.LogOnInfo
            myLogin.ConnectionInfo.ServerName = ConfigurationManager.AppSettings("dbserver")
            myLogin.ConnectionInfo.DatabaseName = ConfigurationManager.AppSettings("dbname")
            myLogin.ConnectionInfo.Password = ConfigurationManager.AppSettings("dbpassword")
            myLogin.ConnectionInfo.UserID = ConfigurationManager.AppSettings("dbuser")
            myTable.ApplyLogOnInfo(myLogin)
        Next
        Me.CrystalReportViewer1.ReportSource = report1
    End Sub

Public Class viewer
    Dim report1 As New ReportDocument
    Public nameRpt As String

    Private Sub assignreport()
        If nameRpt = "Invoice" Then
            report1 = New Invoice1
            param1()
            Me.Text = "Invoice"
    end if
End Sub

Private Sub param1()
        Dim rec As New CrystalDecisions.Shared.ParameterValues()
        Dim Drecordno As New CrystalDecisions.Shared.ParameterDiscreteValue()
        Dim word As New CrystalDecisions.Shared.ParameterValues()
        Dim Dword As New CrystalDecisions.Shared.ParameterDiscreteValue()
        Dim RF As New CrystalDecisions.Shared.ParameterValues()
        Dim DRFNo As New CrystalDecisions.Shared.ParameterDiscreteValue()
        report1.Refresh()
        If nameRpt = "Invoice" Or nameRpt = "Invoice2" Then
            Drecordno.Value = CInt(Invoicing.c1txtrec.Value)
            DRFNo.Value = Invoicing.RFNo
            RF.Add(DRFNo)
            report1.DataDefinition.ParameterFields("@RFNo").ApplyCurrentValues(RF)
        End If
        rec.Add(Drecordno)
        report1.DataDefinition.ParameterFields("@rec").ApplyCurrentValues(rec)
     End Sub
End class

Thanks.

Susan Low

Edited by: Don Williams on Jan 9, 2012 1:05 PM

0 Kudos

Hi Susan,

Couple of things you should change. When you load the report then set the log on info then and then set the parameter values, not when you preview the report.

From what it looks like the flow is:

Load the report, Set the Log on info, VIEW the report and then set the Parameters.

Viewing the report should be the last call you make. Can't explain why this worked before though...

Oh and this Kbase may help also:

[1201559 |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233303331333533353339%7D.do]- Viewing the report in the Windows Forms Viewer ignores the record selection formula

Don

Edited by: Don Williams on Jan 9, 2012 1:18 PM