Please help me on how can I refresh the records displayed in my crystal report.
because when i first open a report it functions well but if I close the report viewer form then open it again the previous records will display with the new records that i selected

example if i select * from tblname name it will display:

1 |pedro |san jose

but when i close it and open it again with the same query it will now become

1 |pedro |san jose
1 |pedro |san jose

I need to close the entire project just to remove the duplicate record

what i need is like listview1.items.clear but in crystal report

this is my code

'====================this is the code to display the form where you can find the crystal report viewer====
    Private Sub ButtonXView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonXView.Click
             With CHDepartmentReportViewer
        End With
    End Sub

'=====================this is the code inside my CHDepartmentReportViewer===============================

    Option Strict On
    Imports MySql.Data.MySqlClient
    Imports CrystalDecisions.CrystalReports.Engine
    Public Class CHDepartmentReportViewer
        Private Sub CHDepartmentReportViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim strReportName, strReportPath As String
                strSQL = "Select * from tbl_medicine_inventory i, tbl_medicine_brand_list b, tbl_medicine_description_list d where b.medicine_id = i.relation_medicine_id and d.medicine_description_id = i.relation_medicine_description_id ORDER BY batch_no DESC"

                cmd = New MySqlCommand(strSQL, Connection)
                Dim da As New MySqlDataAdapter
                da.SelectCommand = cmd
                strReportName = "CrystalReportCityHealthDepartmentIventory"
                strReportPath = Application.StartupPath & "\" & strReportName & ".rpt"
                Dim RptDocument As New ReportDocument
                'RptDocument.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape
                With CrystalReportViewer1
                    .ReportSource = RptDocument
                    '.ShowRefreshButton = False
                    '.ShowCloseButton = False
                    '.ShowGroupTreeButton = False
                End With
            Catch ex As Exception
                MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End Try

        End Sub
    End Class

I hope I explained myself clear

i found the answer for this problem, I will share it because it will be helpful for those who will encounter this ,, i just clear the dataset before calling it,, you can put

ds.clear() inside the form load on top of all the other codes

Be a part of the DaniWeb community

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