ANmarS - Search results

Excel/VBA expert since Sep 1997 (20 years 9 months)

We are moving ...

We are moving to another location, better, faster and more resources .... check it out ANmar.Systems

1 Q & A posts tagged with ADODB

Jan 20

Debug error 3001 on VBA when I try a sequential search of the database.?

I am trying to subtract the quantity ordered by a customer by the Number In Stock of a particular product. To do this, I needed a sequential search, and I used a code which I thought of. However, it brings up a "Run-time error '3001': Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
The Debug error is this:
rst.Find "ProductID = " & Me!ProductID, 0, adSearchForward, 1
Here is the code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Dim con As New ADODB.Connection
Dim rst As ADODB.RecordSet

Set con = CurrentProject.Connection
Set rst = New ADODB.RecordSet

rst.Open "tblProduct", con, adOpenKeyset, adLockOptimistic

rst.Find "ProductID = " & Me!ProductID, 0, adSearchForward, 1
rst("NumberInStock") = rst("NumberInStock") - Me!QuantityOrdered

Set rst = Nothing
Set con = Nothing

End If
End Sub


- Is the name of field you want to search in named "ProductID" too?
- Did you gave all arguments of "Find"?
- What about the result of Find, shouldn't you assign the result to a variable?
- Are ProductID columns from both sides in the same type?


Tuesday 1/20/2009 2:05:12 PM