0

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

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by snurd
0

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

Edited by abu taher: n/a

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.