My search command is looking for a Part by it's description. The following code works great for an exact match search but I would like a code that will go to the closest match in the recordset. Any help will be appreciated....

Private Sub search_cmd_Click()
Dim txtsid As String
Dim Founder As Boolean

txtpart = UCase(InputBox("Enter Part Description:", "Description Search"))
If Len(txtpart) > 0 Then
Data1.Refresh
Data1.Recordset.MoveFirst
Founder = False
End If

Do While (Not Founder) And (Not Data1.Recordset.EOF)

If UCase(Data1.Recordset.Fields("Description").Value) = txtpart Then
Founder = True
Exit Sub
End If
Data1.Recordset.MoveNext
Loop

If Not Founder Then
MsgBox "Unable to find the required item", , "Not Found"
Data1.Recordset.MoveLast
End If
End Sub

This was a small modification of "abu taher"s code which works very well. I just need it to go to the closest match. Thanks "abu taher".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.