Link to home
Start Free TrialLog in
Avatar of Karolina Sanovic
Karolina Sanovic

asked on

search by any word in column

I have code for search and everything works but I would like my last column named napomena(reminder) to make search by any word inside the column because I cant write all text from column.




  Private Sub Buttonsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsearch.Click
        school = cmbSearch.Text

        Select Case school
            Case "datum"
                Me.NapomenaBindingSource.Filter = "datum='" & txtSearch.Text & "'"
            Case "pčelinjak"
                Me.NapomenaBindingSource.Filter = "pčelinjak=  '" & txtSearch.Text & "'"
            Case "košnica br"
                Me.NapomenaBindingSource.Filter = "[košnica br]='" & txtSearch.Text & "'"
            Case "napomena"
                Me.NapomenaBindingSource.Filter = "napomena= '" & txtSearch.Text & "'"

        End Select

        If NapomenaBindingSource.Count <> 0 Then
            With NapomenaDataGridView
                .DataSource = NapomenaBindingSource
            End With
        Else
            Me.notFound()

        End If
    End Sub

Open in new window

code-search-by-word.png
search-by-word.png
Avatar of Dorababu M
Dorababu M
Flag of India image

Not clear what exactly you are trying to achieve can you explain a bit further
try use the like clause, quick try:

Me.NapomenaBindingSource.Filter = "napomena like '%" & txtSearch.Text & "%'"

Open in new window

Avatar of Karolina Sanovic
Karolina Sanovic

ASKER

I have column napomena(reminder) and I put in that column text with some informations and I want to search  not needed to write whole informations.Example in my column I have written "John Smith is a boy 10.years" I want in my textbox for search to writte Smith and get searched and be found
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It works,thanks