General discussion


Listview sub item search

By greg85374 ·
I have a lstview control called LstViewReminder
the field in it are:
Lv.SubItems(1) = Rs("Date")
Lv.SubItems(2) = Rs("Time")
Lv.SubItems(3) = Rs("EntryType")
Lv.SubItems(4) = Rs("Name")
Lv.SubItems(5) = Rs("Address")
Lv.SubItems(6) = Rs("City")
Lv.SubItems(7) = Rs("State")
Lv.SubItems( = Rs("Zip")
Lv.SubItems(9) = Rs("HomePhone")
Lv.SubItems(10) = Rs("CellPhone")
Lv.SubItems(11) = Rs("WorkPhone")
Lv.SubItems(12) = Rs("Ext")
Lv.SubItems(13) = Rs("Notes")

Ive a cbobox named CboSearchBy- that loops through my fields and add them to itsself.
and a Textbox named TxtEmpSearch

The user should be able to select the coulumnheader(one of my Lv's)then enter a search string in the txtbox

upon pressing CmdSearch I want it to search my listview's subitems for a match with the textbox.

I used the code:
Private Sub CmdSearch_Click()
Dim I, X As Integer
Dim strchk As Variant

If Not Rs.BOF Then
End If

For I = 1 To Rs.Fields.Count - 1
If LstViewReminder.ColumnHeaders(I).Text = CboSearchBy.Text Then
X = (I - 1)
End If
Next I

For I = 1 To LstViewReminder.ListItems.Count
If TxtEmpSearch.Text = LstViewReminder.ListItems(I).SubItems(X)Then
MsgBox "Match Found!" + vbNewLine + "Employee I " + LstViewReminder.ListItems(I).Text, , "Record(s) Found Are In Bold"
LstViewReminder.ListItems(I).Bold = True
LstViewReminder.ListItems(I).Selected = True
Exit Sub
End If
Next I

TxtEmpSearch.Text = ""
End Sub
which worked fine for a while..unfortuantely now im getting an error:runtime error 380 invalid property value. This is the first time ive used this control and owuld like to know what im doing wrong and how to correct it!

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Related Discussions

Related Forums