Feedback from acCmdDeleteRecord & cascading deletes

R

RzB

I have a delete button on a form that shows
a bound record.

I use docmd.RunCommand acCmdDeleteRecord
to delete the record as required.

If the record has relationships with other records
with cascading delete turned on, the user gets a
horidly worded warning, and is given the choice
of progressing with the delete or canceling.

I have two questions.

1. If I use this mechanism and the user chooses
to cancel the delete, it would appear that I get
an error code returned of
"3021 = No Current record" - Is this correct?
I have read that there is some problem with
Access 2002 SP3 and that error code.
Am I ok to rely on this error code?

2. I would really like to handle this with code
(prior to doing the delete) to tell the user
that deleting this record, will delete other records,
(in terms he understands). Then do the delete if
they still want to, with docmd.setwarnings false.
However I just don't know where to start to get
the cascaded delete information I need.

Any pointers would be appreciated..

Thanks,
Roy
 
G

Guest

You can code around this. The way to do it is run it to see what the error
number is. Then put error handling in the event where you attempt the delete
that will trap for that error and allow you to display your own message and
do what you want from there.

I am concerned about cascading deletes. Is it possible any of the records
that may be deleted could also be related to other records in your table? If
so, a cascade delete can cause havoc in your database. Perhaps you should
consider alternatives.
 
R

RzB

Klatuu,
Many thanks for your response...

...
You can code around this. The way to do it is run it to see what the
error
number is. Then put error handling in the event where you attempt the
delete
that will trap for that error and allow you to display your own message
and
do what you want from there.

Yes - I had already done that - that is how I know
I get a "3021 = No Current record" What I'm concerned
about is some discussion about an Access problem relating
to this error. See....

http://makeashorterlink.com/?M2363623B

Can I rely on this error code in this application?
I am concerned about cascading deletes. Is it possible any of the records
that may be deleted could also be related to other records in your table?
If
so, a cascade delete can cause havoc in your database. Perhaps you should
consider alternatives.

No No... The db works just fine.. The cascading
deletes work exactly how I want them to.
It's a very useful mechanism ...

What I need to know is how to inspect the
cascades from VBA. I have tried to find out from
the books I have and the web but have come
up with nothing...

Many thanks,
Roy
 
G

Guest

RzB,

I am not familiar with 2002 at all. I read the info on the link you sent.
Allen Browne seems to be very knowledgible, so I would tend to trust his
opionions. if this is an SP3 bug, I guess the only thing you can do is trap
for it in your error handling code so the user never sees it.
 

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