Q. Generate different reports from Address Book using Microsoft Report and Microsoft Report
Viewer.

Source Code:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DataSet1.bca' table. You can move, or remove it, as needed.
        Me.bcaTableAdapter.Fill(Me.DataSet1.bca)

        Me.ReportViewer1.RefreshReport()
    End Sub

    Public Shared Sub getFilterValues(ByVal type As Integer, ByVal value As String)
        Try
            Select Case type
                Case 0
                    Form1.bcaTableAdapter.FillBy(Form1.DataSet1.bca, value)
                Case 1
                    Form1.bcaTableAdapter.FillBy1(Form1.DataSet1.bca, value)
            End Select
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        Form1.ReportViewer1.RefreshReport()
    End Sub
    Private Sub FilterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilterToolStripMenuItem.Click
        FilterForm.Show()
        FilterForm.Focus()
        Me.Hide()
        FilterForm.TxtValue.Clear()
    End Sub
End Class
***************************************************************************

Public Class FilterForm

    Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
        Form1.getFilterValues(CB.SelectedIndex, TxtValue.Text)
        Form1.Show()
        Form1.Focus()
        Me.Hide()
    End Sub

    Private Sub CancelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelButton.Click
        Form1.Show()
        Me.Close()
    End Sub
End Class

Comments

Popular posts from this blog