hi there ...a pleasant day/evening...i am wrking for a code...wat i wnt to happen s dat in the combobox category when i click all, all d items dsplay but wen i click specific category somethng went wrong with my code..i cannot view all d items under with the choosen category...pls help me...here is my code...

If cboscategory.Text = "" Then
MsgBox "Select from the category"
ElseIf cboscategory.Text = "All" Then
If rs.State = adStateOpen Then rs.Close
   rs.Open "Select * from tbllistgood ", cn, adOpenKeyset, adLockPessimistic
While Not rs.EOF
        With frmlist.ListView2.ListItems.Add(, , rs!category)
            With .ListSubItems
                .Add , , rs!code
                .Add , , rs!nmeitem
                .Add , , rs!rprice
            End With
        End With
        rs.MoveNext
    Wend
Else
If rs.State = adStateOpen Then rs.Close
   rs.Open "Select * from tbllistgood where category like '" & cboscategory.Text & "';", cn, adOpenKeyset, adLockPessimistic
While Not rs.EOF
        With frmlist.ListView2.ListItems.Add(, , rs!category)
            With .ListSubItems
                .Add , , rs!code
                .Add , , rs!nmeitem
                .Add , , rs!rprice
            End With
        End With
        rs.MoveNext
    Wend
End If

End Sub

I am not sure what you are trying to do...

But, you might try adding a List Box to display the sub-items from the Combo-Box Selection.

In other words, only populate the ComboBox with the primary selections...

Then when a selection is made in the ComboBox, use its text Field to load the sub-items into the adjacent ListBox...

On line 18, your "like" clause needs some wildcards. Otherwise, you'll only get hits when category is equal.

Here is your cause of problem.

this line-> rs.Open "Select * from tbllistgood where category like '" & cboscategory.Text & "';"

change last portion to "%';"


DONE.

This article has been dead for over six months. Start a new discussion instead.