append query error due to key or index violation

G

Guest

does anybody know the error number associated with the error "Microsost
Office Access can't append all the records in the append query" I know why I
am getting the error. I am trying to produce a certain message if this error
is encountered.

I have
on error goto dup_if

dup_if:
if err= x then
retvalue=msgbox("value already exists",vbokonly)
docmd.cancelevent
else
exit sub
end if
end sub

I can get the message to pop up if I leave the if err= statement out but I
only want it to pop up for that specific error.

Thanks in advance for any help.
 
G

Guest

I don't know the number, but to find it, go into debug mode, put a breakpoint
on the line:
if err= x then
Then when it stops at the line, in the immediate window type in:
?err.number
 
G

Guest

Klatuu said:
I don't know the number, but to find it, go into debug mode, put a breakpoint
on the line:
if err= x then
Then when it stops at the line, in the immediate window type in:
?err.number

Thanks. Turns out the error number is 0. Unfortunately the regular action
query warnings are invoking the same code even though I have turned off the
confirm option for action queries. Any ideas?
 
J

JohnGriffiths

Silly question, do you have an Exit Sub/Exit Function before the
dup_if: label ?

Otherwise the program will continue from normal functioning into your error
handler.

Regards John
 
G

Guest

I don't. But I have modified my approach to write directly to a table rather
than using an append query. Thanks for trying to help though
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top