INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ADODB Recordset Error when using .Find on alphanumeric criteria

ADODB Recordset Error when using .Find on alphanumeric criteria

(OP)
I have a VB6.0 application, using ADODB recordset to find a record for a searched criteria. It only errors out when searching on Alphanumeric data. It works when searching on numeric data. The Error Number is 3001. The Error Message is "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.".

Below is the code, where .Find line would error out.

'ItemQuery = "1340079" 'This item works
'ItemQuery = "0200560" 'This item works
ItemQuery = "NS" 'This item errors out

RecordSet_PriceList.MoveFirst
RecordSet_PriceList.Find RecordSet_PriceList.Fields(0).Name & " = " & ItemQuery
If RecordSet_PriceList.EOF = False Then 'find the item
'Do my stuff here....
End If

The ADO recordset is opened to pull from an Excel worksheet as : [rs.Open "Select * from [" & sSheetName & "$]", objAdCon, adOpenKeyset, adLockOptimistic]

Can you please direct me to a good fix? Any input is appreciated.






RE: ADODB Recordset Error when using .Find on alphanumeric criteria

Did you try:

CODE

ItemQuery = "NS" 'This item errors out

With RecordSet_PriceList
    .MoveFirst
    .Find .Fields(0).Name & " = '" & ItemQuery & "'"
    If .EOF = False Then 'find the item
        'Do my stuff here....
    End If
End With 

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: ADODB Recordset Error when using .Find on alphanumeric criteria

Hi,

Queries don't like Text and Numbers in the same column!!!

The query looks at the data in your column and assumes its numeric. It encounters the alpha and TILT!

RE: ADODB Recordset Error when using .Find on alphanumeric criteria

Can you change the format of the price list field to text in the original database? If so it will handle both but the sorting order will be on the first number so 6 will come after 10.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close