Results 1 to 4 of 4

Thread: Runtime error 3001 'Arguments are of the wrong type or out of acceptable range...

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2017
    Posts
    2

    Unhappy Runtime error 3001 'Arguments are of the wrong type or out of acceptable range...

    Hey Guys

    I have a little problem.

    I want to filter the DataGrid in Visual Basic 6. I am using this code

    Code:
    Adodc1.Recordset.Filter = "columnname like '%" + Me.Txtsearch.Text + "%'"
    All went well. when I put the words "a" in the textbox then, the data that is the letter "a" will appear. But when the letter was removed from the textbox, appears an error like this

    Runtime error 3001 'Arguments are of the wrong type or out of acceptable range, or are in conflict with one another'
    Here is a screenshot of the error:

    Name:  jJLIR.jpg
Views: 1653
Size:  35.1 KB

    Can anyone explain to me why this happens ?

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Runtime error 3001 'Arguments are of the wrong type or out of acceptable range...

    I think you should check whether the textbox has any content.
    If there is no content you can not filter on '%%'
    Code:
    If Len(Txtsearch.Text) > 0 Then
      Adodc1.Recordset.Filter =  "columnname like '%" + Me.Txtsearch.Text + "%'"
    Else
      Adodc1.Recordset.Filter =  ""
    End If

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Runtime error 3001 'Arguments are of the wrong type or out of acceptable range...

    that's probably the better way to go. The reason the original code doesn't work is because it results in "like '%%' " ... which is invalid... '%' would be valid.
    Either way, you need to check to see if there is anything to filter on or not, and act accordingly, preferably as shown in post 2.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2017
    Posts
    2

    Re: Runtime error 3001 'Arguments are of the wrong type or out of acceptable range...

    Oh Thanks. It's solved now. Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width