Here is an example, but obviously you would use your recordset to query a database instead of the way I did it and made it a disconnected recordset.
VB Code:
Dim rsList As New ADODB.Recordset 'instead of appending fields you would do a query and open 'your recordset with the appropriate fields. rsList.Fields.Append "Name", adBSTR rsList.CursorType = adOpenStatic rsList.LockType = adLockOptimistic rsList.Open 'I am adding two records for test data, but you would 'already have data from your query rsList.AddNew rsList.Fields("Name") = "Greg" rsList.AddNew rsList.Fields("Name") = "Joe" 'now just loop through and highlight any items that are equal rsList.MoveFirst For i = 1 To rsList.RecordCount For n = 0 To List1.ListCount If List1.List(n) = rsList("Name") Then List1.Selected(n) = True Exit For End If Next rsList.MoveNext Next rsList.Close Set rsList = Nothing





Reply With Quote