View Full Version : Run Time error 2001 without apparent reason


firework
01-23-2008, 02:21 AM
Hi,

The following keep coming up and I didn't do any cancelling operation.

Run-Time error '2001' You canceled the previous operation. My code is

If DCount("[CategoryID]", "TCategory", "[Category] ='" & Me!Category & "'") = 0 Then
DoCmd.RunSQL "INSERT INTO TCategory (CatSeq, Category) values (Me!CatSeq, Me!Category)"
End If

I have already tried compact and repair but doesn't work.

firework
01-23-2008, 02:23 AM
Additional info

MSAccess 2003 but 2000 file format, Win XP pro, Office sp3 and hotfix for sp3

chergh
01-23-2008, 03:34 AM
Try:


If DCount("[CategoryID]", "TCategory", "[Category] =" & Me!Category) = 0 Then

firework
01-23-2008, 09:29 AM
Tried that but same result

ByteMyzer
01-23-2008, 10:12 AM
Try changing:

DoCmd.RunSQL "INSERT INTO TCategory (CatSeq, Category) values (Me!CatSeq, Me!Category)"

...to

CurrentDb.Execute "INSERT INTO TCategory (CatSeq, Category)" _
& " VALUES (" & Me!CatSeq & ", '" & Me!Category & "')"

NOTE: The above recommendation assumes that CatSeq is a numeric field and that Category is a text field. Single-quotes (') are added for the text field, but omitted for the numeric field.

See if this works for you.