Run Time error 2001 without apparent reason

firework

Registered User.
Local time
Today, 12:11
Joined
Dec 15, 2007
Messages
42
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.
 
Additional info

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

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

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

...to
Code:
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.
 

Users who are viewing this thread

Back
Top Bottom