The following function searches a listview and seeks out a string - then sets the focus to the item
What I want to be able to do is find an item by reference to two subitems
For instance the first subitem will be a date and the second will be a time
I can currently find the date in the first subitem - how do I search for the second subitem ?
Private Function FindIt(LV As ListView, str As String, Optional iCol As ListFindItemWhereConstants)
' FindItem method.
'Create an integer variable called intSelectedOption
' to store the index of the selected button
' Create a string variable called strFindMe. Use the InputBox
' to store the string to be found in the variable. Use the
' FindItem method to find the string. Option1 is used to
' switch the FindItem argument that determines where to look.
Dim intSelectedOption As Integer
Dim strFindMe As String
If Len(str) = 0 Then str = "0"
strFindMe = str
intSelectedOption = iCol 'lvwText
' FindItem method returns a reference to the found item, so
' you must create an object variable and set the found item
' to it.
Dim itmFound As ListItem ' FoundItem variable.
Set itmFound = LV.FindItem(strFindMe, intSelectedOption, , 0)
' If no ListItem is found, then inform user and exit. If a
' ListItem is found, scroll the control using the EnsureVisible
' method, and select the ListItem.
If itmFound Is Nothing Then ' If no match, inform user and exit.
' MsgBox "No match found"
' fall through
itmFound.EnsureVisible ' Scroll ListView to show found ListItem.
itmFound.Selected = True ' Select the ListItem.
' Return focus to the control to see selection.