-
Mar 16th, 2017, 08:19 AM
#1
Thread Starter
New Member
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:
Can anyone explain to me why this happens ?
-
Mar 16th, 2017, 08:46 AM
#2
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
-
Mar 16th, 2017, 09:24 AM
#3
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
-
Mar 17th, 2017, 03:09 AM
#4
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|