Searching Data from DataGrid Control using ADODC in VB6.0

18,890

When the field you're searching in is not a numeric type, you'll want to delimit it with single quotes:

Adodc1.Recordset.Find "L_No = '" & item & "'"
Share:
18,890
Santosh
Author by

Santosh

I'm a student.

Updated on June 04, 2022

Comments

  • Santosh
    Santosh almost 2 years

    I'm a student doing my final year mini project and am facing a problem related to searching data in the datagrid. The error I'm getting is :

    Run-time error : '3001' Arguments are of wront type, are out of acceptable range, or are in conflict with one another

    The code is :

    Private Sub Command1_Click()
    Dim item As String
        Adodc1.Recordset.MoveFirst
        item = Text1.Text
        Adodc1.Recordset.Find "L_No = " & item
        If Adodc1.Recordset.EOF Then
            MsgBox "Record Set not found"
        End If
    End Sub
    

    The above code is working when the data I'm searching is only number. For example When I search the data on the basis of L_Id which is a License ID an Integer value the searching is done and I'm getting the result. When I search the data on the basis of L_No which is a License Number a string value which consists of both numbers and alphabets I'm getting the above error.

    Do I have to parse the value is text1.text or do anything else?