Hello there Good Day Guys!

I need your expertise for vb6 guys i made a small program with command search button. Its working. My problem now when i search again with different category it shown this error

Run-time error '3001'

Argument are of the wrong type, or out of acceptable range, or are
in conflict with another.

here's the code:

Private Sub cmdSearch_Click()
    Dim EQP As String
    
    With Adodc1.Recordset
        
    If Trim(cmbCategory.Text) <> "" Then
            
    If cmbCategory.Text = "All" Then
        txtTitle.Text = ""
        txtFDirector.Text = ""
            
     Else
     
        EQP = "Category = '" & cmbCategory.Text & "'"
        End If
    End If
            
    If Trim(txtFTitle.Text) <> "" Then
            
        EQP = EQP & " and Title like '*" & txtFTitle.Text & "*'"
                
    End If
            
    If Trim(txtDirector.Text) <> "" Then
                
        EQP = EQP & " and Director like '*" & txtFDirector.Text & "*'"
                
    End If
            
        If Trim(txtFVN.Text) <> "" Then
        If cmbCategory.Text = "all" Then
            EQP = "VideoNumber like '*" & txtFVN.Text & "*'"
            
        Else
                   
            EQP = EQP & " AND VideoNumber like '" & txtFVN.Text & "'"
            End If
                    
        End If
                    
            .Filter = EQP
                
        End With
            
            If Adodc1.Recordset.RecordCount > 0 Then
            lblAvailable.Caption = "Available: " & Adodc1.Recordset.RecordCount
           
        Else
            lblAvailable.Caption = " Available: 0"
            MsgBox "No record to Display!", vbInformation, "Filter"
        
        End If
End Sub
Private Sub Form_Load()
    
    With Adodc1.Recordset
    
    cmbCategory.Clear

Dim i As Integer
Dim st As String
Dim b As Boolean

    cmbCategory.AddItem "all"
    
    Do While Not .EOF
    
    st = .Fields!category
    b = False
   
    For i = 0 To cmbCategory.ListCount - 1

    If st = cmbCategory.List(i) Then
   
    b = True
    End If
Next
    
    If b = False Then
        cmbCategory.AddItem st
        
    End If
    
    .MoveNext
    Loop
End With

    If cmbCategory.ListCount > 0 Then
    cmbCategory.ListIndex = 0
    
Else
    
    cmbCategory.ListIndex = -1
    
    End If
End Sub

on what row are you getting the error

on what row are you getting the error

Sir i got error in row 41

But I try to resolve this problem but i got another error its

run-time error 3265

I cannot be found in the collection corresponding to the requested
name or ordinal...

EQP = EQP & " AND VideoNumber like '" & txtFVN.Text & "'"

you have not used wildcard here

EQP = EQP & " AND VideoNumber like '" & txtFVN.Text & "'"

you have not used wildcard here

What do you sir, what is the correct code i need???

From the Platform SDK help file, Database and Messaging Services, Microsoft Data Access SDK, Microsoft ActiveX Data Objects, ADO Programmer's Reference, Error Codes:

adErrInvalidArgument 3001
0x800A0BB9
The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another.

adErrItemNotFound 3265
0x800A0CC1
ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application.

Basically the 3001 error means that you are trying to use an invalid comparison. The 3265 error means you have an invalid column or table name. I suggest you put a breakpoint on line 36 and examine the contents of your EQP variable to see what is coming out. Make sure your column names are correct, then check to see if the datatypes correspond to the expected column datatypes. Perhaps you are getting a numeric compared to an alpha character, or embedded non-printable characters...impossible to know until you look. You might also consider whether there are embedded quotes in any of the text boxes...that can raise havoc with SQL Server.

commented: Excellent comments based on experience and in depth understanding of the subject matter. +5

EQP = EQP & " AND VideoNumber like '" & txtFVN.Text & "'"

write this line as

if using access

EQP = EQP & " AND VideoNumber like '%" & txtFVN.Text & "'"

if using sql server
EQP = EQP & " AND VideoNumber like '*" & txtFVN.Text & "'"

I cannot be found in the collection corresponding to the requested
name or ordinal...

I would agree with BitBlt. I've seen that error popup when I misspelled the field name. In other words, the requested name does not exist because of my spelling error.

Sometimes I err on the side of caution and go ahead and convert a text value to a number. I know VB6 usually goes ahead and converts a string value to a numeric data type; but I err on the side of caution and convert the string value to a numeric type before sticking it into the Sequel statement just out of habit from using other programming languages that don't allow this flexibility.

Anyone please help me to sort out this problem. I gor run time error 3001 when using following code

Private Sub Form_Load()
connection

Set rs = New ADODB.Recordset
rs.Open "select * from student ", CN, adOpenDynamic, adLockOptimistic
End Sub

@manafva,

Please open your own thread with your question. This thread belongs to someone else...

change code

connection

to

Call connection

provided that it is in the same form module or declared publically...

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.