what causes Runtime Error '3001' Arguments? (1 Viewer)

bonekrusher

Registered User.
Local time
Today, 01:34
Joined
Nov 19, 2005
Messages
266
I have 2 list boxes, where you can move items from one list box to another. It works fine except when there is certian data. 95% of my data works and select items don't. I get the following error "Runtime Error '3001' Arguments are of the wrong type, are out of acceptable
range or are in conflict with one another"

here is the code:

Private Sub cmdAdd_Click()

Dim conn As ADODB.Connection
Dim MyRS As ADODB.Recordset
Dim SelItem As Control

' set SelItem = to the selected item.
Set SelItem = Me.ListYes

If IsNull(SelItem) Then
MsgBox "You have to select an item! Please select an item from the list."
Else
' set up the connection and recordset.
Set conn = CurrentProject.Connection
Set MyRS = New ADODB.Recordset

' open the recordset.
MyRS.Open "Table1", conn, adOpenDynamic, adLockOptimistic

With MyRS
' find the record for the selected item.
.Find "List_Item = '" & SelItem & "'"
' set the Yes-No_Fld of the selected record to "No".
.Fields("Yes-No_Fld").Value = "No"
.Update
End With

Set MyRS = Nothing
Set conn = Nothing

' make sure the list boxes have the current values.
Me.ListYes.Requery
Me.ListNo.Requery
End If

End Sub
 

bonekrusher

Registered User.
Local time
Today, 01:34
Joined
Nov 19, 2005
Messages
266
One more thing. The items in the list boxes are questions (test field (255)). Only the ones that start with the word "Does" gives me the error...

Thanks
 

bonekrusher

Registered User.
Local time
Today, 01:34
Joined
Nov 19, 2005
Messages
266
solution

I fixed it. The soltion was in the line:

.Find "List_Item = '" & SelItem & "'"

I changed the ' to a #

.Find "List_Item = #" & SelItem & "#"

Now it works great...
 

DixieDean

New member
Local time
Today, 09:34
Joined
Nov 15, 2005
Messages
1
Nice one BoneKrusher

Mate,

I've been dwelling on this one all day. Just happened to stumble on your post by chance.

Now everything is sweet, the world is a beautiful place, and I can go and get drunk.

Great stuff!!!!
 

RuralGuy

AWF VIP
Local time
Today, 02:34
Joined
Jul 2, 2005
Messages
13,826
Does this also work?
Code:
.Find "List_Item = " & Chr(34) & SelItem & Chr(34)
Does your SelItem have an apostrophy in it?
 

Users who are viewing this thread

Top Bottom