hello everyone i need help with a search button for visual basic 6.0 however im getting a run-time error '3077' error

Private Sub search_cmd_Click()
Dim txtsid As String
txtsid = InputBox("Enter The Staff ID In Lowercase", "Staff Search")
If txtsid = "" Then Exit Sub

If MsgBox("Would You Like To Start The Search From The First Record?", vbYesNo + vbInformation, "Start The Search Location") = vbYes Then
Data1.Recordset.MoveFirst
End If
Data1.Recordset.FindNext "staffid'" & txtsid & "*'"
If Data1.Recordset.NoMatch = True Then
MsgBox "No MAtch Was Found", vbOKOnly + vbCritical, "Search Faild"
End If

End Sub

I would like the help

please try this.

Dim txtsid As String
    Dim Founder As Boolean

    txtsid = UCase(InputBox("Enter The Staff ID:", "Staff Search"))
    If Len(txtsid) > 0 Then
        'add this line
        Data1.Refresh
        Data1.Recordset.MoveFirst
        Founder = False
    End If

    Do While (Not Founder) And (Not Data1.Recordset.EOF)
        'u can add UCASE i just removed it for my query
If UCase(Data1.Recordset.Fields("staffid").Value) = txtsid 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

This code works excellent for an exact match but is there a way to goto the closest match?

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.