ADO error trapping in called function

J

jwkeene

I have a form (in an Access Project) within which (using OnClick for a
command button) I create a connection to a SQL/Server database; I then create
a Command object pointing to that connection. Later on in the OnClick routine
I call a function that adds a record to a table in the database by passing
the command object to the function. I am trying to trap the duplicate key
error. If I set On Error in the form (in the command button On Click routine
that set sthe Add in motion), the trap closes and I "see" the error in the
button's error handler. If I set On Error in the called function, the error
is not "seen" in the function. I have tried moving the connection and the
command objects around (into globals); I have tried passing the connection to
the function and then instantiating a commnd object in the function. In
everything I have tried the ADO error is eluding the trap in the function,
but getting snared in the trap in the OnClick routine. (The On Error in the
function does trap other application-based errors, so it appears to be
working on some level.) This looks like a "scope" problem, but I can't figure
out how to get the trap to close in the function. Can anybody help?
 

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