I have an Access database, with a VB front-end. I have coded a button to search for records. The button works, but only if the record (in this case, a Surname) is typed in exactly. It does not work for wildcard searching (eg: *smi* to find all names containing those letters. I would have to type 'Smith' in full).
Does anyone have any ideas how my code (as follows) can be modified to enable this feature?
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim FindName As String
Dim DataPosition As Integer
FindName = InputBox("Please enter surname to search for")
If FindName <> "" Then
Dim cm As CurrencyManager = CType(BindingContext _
(DataSet12, "tblData"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
DataPosition = dv.Find(FindName)
If DataPosition > -1 Then
Me.BindingContext(DataSet12, _
"tblData").Position = DataPosition
End If
End If
End Sub
Many thanks for your help!
Does anyone have any ideas how my code (as follows) can be modified to enable this feature?
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim FindName As String
Dim DataPosition As Integer
FindName = InputBox("Please enter surname to search for")
If FindName <> "" Then
Dim cm As CurrencyManager = CType(BindingContext _
(DataSet12, "tblData"), CurrencyManager)
Dim dv As DataView = CType(cm.List, DataView)
DataPosition = dv.Find(FindName)
If DataPosition > -1 Then
Me.BindingContext(DataSet12, _
"tblData").Position = DataPosition
End If
End If
End Sub
Many thanks for your help!