Hi!

Please help me with my search functionality...searching using textbox and retrieving the data into a listview. here is my code:

openrstJCcaseInfo "select * from JCcaseInfo"
        If Not rstJCcaseInfo.EOF Then
            caseinfo.ListItems.Clear
            Dim m
            With rstJCcaseInfo
                While .EOF = False
                    If LCase(txtsearch.Text) = LCase(rstJCcaseInfo.Fields("CaseTitle").Value) Then
                    Set ls = caseinfo.ListItems.Add(, , rstJCcaseInfo.Fields("CaseStatus").Value)
                        ls.SubItems(1) = rstJCcaseInfo.Fields("CaseVenue").Value
                        ls.SubItems(2) = rstJCcaseInfo.Fields("Place").Value
                        ls.SubItems(3) = rstJCcaseInfo.Fields("CaseTitle").Value
                        ls.SubItems(4) = rstJCcaseInfo.Fields("CaseNo").Value
                        ls.SubItems(5) = rstJCcaseInfo.Fields("Nature_of_the_Case").Value
                        ls.SubItems(6) = rstJCcaseInfo.Fields("HandlingLawyer").Value
                        ls.SubItems(7) = rstJCcaseInfo.Fields("Remark").Value
                        ls.SubItems(8) = rstJCcaseInfo.Fields("Aging").Value
                        ls.SubItems(9) = rstJCcaseInfo.Fields("DateOfLatest_order_decision").Value
                        ls.SubItems(10) = rstJCcaseInfo.Fields("Date_of_COF").Value
                        ls.SubItems(11) = rstJCcaseInfo.Fields("Filing_Cab_No").Value
                        ls.SubItems(12) = rstJCcaseInfo.Fields("Cab_Drawer_No").Value
                    m = 1
                    End If
                    .MoveNext
                Wend
                .Close
            End With
        End If

what i wanted is, all the data will show into the list view, by just typing the first letter of the data/info.
please help me!!!

Manipulate your sql query to receive input from textbox and put the code in textbox_change() event..

Private Sub Text1_Change()
' your code here
End Sub
Private Sub txtsearch_Change()
If Combo1 = "" Or Combo2 = "" Then
        MsgBox ("You need to specify Case Venue!"), vbInformation
    Else
    openrstJCcaseInfo "select * from JCcaseInfo"
    If Not rstJCcaseInfo.EOF Then
        caseinfo.ListItems.Clear
        Dim m
        With rstJCcaseInfo
            While .EOF = False
                If LCase(txtsearch.Text) = LCase(rstJCcaseInfo.Fields("CaseTitle").Value) Then
                Set ls = caseinfo.ListItems.Add(, , rstJCcaseInfo.Fields("CaseVenue").Value)
                    ls.SubItems(1) = rstJCcaseInfo.Fields("Place").Value
                    ls.SubItems(2) = rstJCcaseInfo.Fields("CaseTitle").Value
                    ls.SubItems(3) = rstJCcaseInfo.Fields("CaseNo").Value
                    ls.SubItems(4) = rstJCcaseInfo.Fields("Nature_of_the_Case").Value
                    ls.SubItems(5) = rstJCcaseInfo.Fields("HandlingLawyer").Value
                    ls.SubItems(6) = rstJCcaseInfo.Fields("Remark").Value
                    ls.SubItems(7) = rstJCcaseInfo.Fields("Aging").Value
                    ls.SubItems(8) = rstJCcaseInfo.Fields("DateOfLatest_order_decision").Value
                    ls.SubItems(9) = rstJCcaseInfo.Fields("Date_of_COF").Value
                    ls.SubItems(10) = rstJCcaseInfo.Fields("Filing_Cab_No").Value
                    ls.SubItems(11) = rstJCcaseInfo.Fields("Cab_Drawer_No").Value
                m = 1
                End If
                .MoveNext
            Wend
            .Close
        End With
    End If
End If
end sub

this is my full code of my search...i don't know what's lacking with this in which the result is still the same...:-(

Like i said before to manipulate your SQL Statment :

openrstJCcaseInfo "select * from JCcaseInfo like " & "'%" & txtsearch.Text & "%'"
commented: Good Point :D +4
commented: :D +2

Thanks Jx Man...it works!!!

you're the MAN!!!:-)

You're Welcome, Dude
Then please mark this thread solved

Be a part of the DaniWeb community

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