Form_Filter.vb

 Public Class Form_Filter
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    Friend WithEvents GB As System.Windows.Forms.GroupBox
    Friend WithEvents lblColumn As System.Windows.Forms.Label
    Friend WithEvents cmbOperation As System.Windows.Forms.ComboBox
    Friend WithEvents txtValue As System.Windows.Forms.TextBox
    Friend WithEvents txtStartDate As System.Windows.Forms.TextBox
    Friend WithEvents txtEndDate As System.Windows.Forms.TextBox
    Friend WithEvents BtnOK As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.GB = New System.Windows.Forms.GroupBox()
        Me.txtEndDate = New System.Windows.Forms.TextBox()
        Me.txtStartDate = New System.Windows.Forms.TextBox()
        Me.txtValue = New System.Windows.Forms.TextBox()
        Me.cmbOperation = New System.Windows.Forms.ComboBox()
        Me.lblColumn = New System.Windows.Forms.Label()
        Me.BtnOK = New System.Windows.Forms.Button()
        Me.GB.SuspendLayout()
        Me.SuspendLayout()
        '
        'GB
        '
        Me.GB.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtEndDate, Me.txtStartDate, Me.txtValue, Me.cmbOperation, Me.lblColumn})
        Me.GB.Location = New System.Drawing.Point(16, 8)
        Me.GB.Name = "GB"
        Me.GB.Size = New System.Drawing.Size(336, 40)
        Me.GB.TabIndex = 0
        Me.GB.TabStop = False
        '
        'txtEndDate
        '
        Me.txtEndDate.Location = New System.Drawing.Point(264, 16)
        Me.txtEndDate.Name = "txtEndDate"
        Me.txtEndDate.Size = New System.Drawing.Size(56, 20)
        Me.txtEndDate.TabIndex = 4
        Me.txtEndDate.Text = ""
        Me.txtEndDate.Visible = False
        '
        'txtStartDate
        '
        Me.txtStartDate.Location = New System.Drawing.Point(200, 16)
        Me.txtStartDate.Name = "txtStartDate"
        Me.txtStartDate.Size = New System.Drawing.Size(56, 20)
        Me.txtStartDate.TabIndex = 3
        Me.txtStartDate.Text = ""
        Me.txtStartDate.Visible = False
        '
        'txtValue
        '
        Me.txtValue.Location = New System.Drawing.Point(200, 16)
        Me.txtValue.Name = "txtValue"
        Me.txtValue.Size = New System.Drawing.Size(128, 20)
        Me.txtValue.TabIndex = 2
        Me.txtValue.Text = ""
        '
        'cmbOperation
        '
        Me.cmbOperation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbOperation.Location = New System.Drawing.Point(120, 16)
        Me.cmbOperation.Name = "cmbOperation"
        Me.cmbOperation.Size = New System.Drawing.Size(64, 21)
        Me.cmbOperation.TabIndex = 1
        '
        'lblColumn
        '
        Me.lblColumn.Location = New System.Drawing.Point(8, 16)
        Me.lblColumn.Name = "lblColumn"
        Me.lblColumn.Size = New System.Drawing.Size(104, 16)
        Me.lblColumn.TabIndex = 0
        '
        'BtnOK
        '
        Me.BtnOK.Enabled = False
        Me.BtnOK.Location = New System.Drawing.Point(16, 56)
        Me.BtnOK.Name = "BtnOK"
        Me.BtnOK.Size = New System.Drawing.Size(336, 24)
        Me.BtnOK.TabIndex = 1
        Me.BtnOK.Text = "&OK"
        '
        'Form_Filter
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(362, 84)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.BtnOK, Me.GB})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form_Filter"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.GB.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public strSelect As String

    Private Sub cmbOperation_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbOperation.Click
      

    End Sub

    Private Sub Enable_OK_Btn()
        Dim State As Boolean = True
        If Me.cmbOperation.Text <> "Between" Then
            State = State And Me.cmbOperation.Text <> ""
            State = State And Me.txtValue.Text <> ""
        Else
            State = State And Me.cmbOperation.Text <> ""
            State = State And Me.txtEndDate.Text <> ""
            State = State And Me.txtStartDate.Text <> ""
        End If
        BtnOK.Enabled = State
    End Sub
    Private Sub txtValue_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtValue.TextChanged
        Enable_OK_Btn()
    End Sub

    Private Sub txtStartDate_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtStartDate.TextChanged
        Enable_OK_Btn()
    End Sub

    Private Sub txtEndDate_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEndDate.TextChanged
        Enable_OK_Btn()
    End Sub

    Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click
        strSelect = "Select * From " & "[" & Me.GB.Text & "]" & " Where " & "[" & Me.GB.Text & "]" & "." & Me.lblColumn.Text & " " & Me.cmbOperation.Text
        Select Case Me.Tag
            Case "Number", "Boolean"
                strSelect = strSelect & " " & Me.txtValue.Text
            Case "String"
                If Me.cmbOperation.Text = "Like" Or Me.cmbOperation.Text = "Not Like" Then
                    strSelect = strSelect & " '" & Me.txtValue.Text & "%'"
                Else
                    strSelect = strSelect & " '" & Me.txtValue.Text & "'"
                End If
            Case "Date"
                If Me.txtEndDate.Visible = False Then
                    strSelect = strSelect & "#" & Me.txtValue.Text & "#"
                Else
                    strSelect = strSelect & "#" & Me.txtStartDate.Text & "#" & " And #" & Me.txtEndDate.Text & "#"
                End If
        End Select
        Me.Dispose()
    End Sub


    Private Sub cmbOperation_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbOperation.SelectedIndexChanged
        If cmbOperation.Text = "Between" Then
            Me.txtValue.Enabled = False
            Me.txtEndDate.Visible = True
            Me.txtStartDate.Visible = True
        Else
            Me.txtValue.Enabled = True
            Me.txtEndDate.Visible = False
            Me.txtStartDate.Visible = False
        End If
        Enable_OK_Btn()
        Me.txtValue.Focus()
    End Sub

    'Private Sub Form_Filter_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    '    strSelect = ""
    'End Sub
End Class

Project Homepage: