Getting to the Temp Buffer of a Deleted Record

R

RitaG

Hi.

When a record is deleted in a SubForm I want to update an Access table using
one of the columns of the deleted record. However, I only want to update the
Access table if the User confirms the delete. I tried using the
AfterDelConfirm Event but by that time I don't have access to the deleted row.

I read that the deleted row is stored in a temp buffer. Is there a way that
I can access that buffer?

TIA.

Rita
 
D

Dirk Goldgar

RitaG said:
Hi.

When a record is deleted in a SubForm I want to update an Access
table using one of the columns of the deleted record. However, I only
want to update the Access table if the User confirms the delete. I
tried using the AfterDelConfirm Event but by that time I don't have
access to the deleted row.

I read that the deleted row is stored in a temp buffer. Is there a
way that
I can access that buffer?

How about grabbing the value of the column in the Delete event and
storing it in a module-level variable, then getting it from that
variable in the AfterDelConfirm event? Note that it is possible to
delete multiple records, in which case the Delete event will fire
multiple times, once for each record, before the AfterDelConfirm event
fires. In that case, you'd have to capture multiple values, possibly in
a collection, or maybe in a delimited string.
 
R

RitaG

Thanks Dirk.

That's exactly what I had tried. In the SubForm I used the Delete event to
store what I needed in an array. In the AfterDelConfirm in the SubForm I had
code to delete a row from the table that the Form was attached to using
information from the array. That worked fine but when I tried to move to
another control on the Form I got the following error message several times
"This operation is not supported within transactions".

I then decided to scrap that idea and do the required update in a program
that runs in the background.

However, when I read your response I tried it again, adding code bit by bit
to see what was causing me to get the error message. I finally realized that
I needed to get the original row back again from the Form that I had deleted
the row (in the SubForm) from. Once I did that (in the AfterDelConFirm Event)
everything worked as I wanted it to!

Rita
 
D

Dirk Goldgar

RitaG said:
Thanks Dirk.

That's exactly what I had tried. In the SubForm I used the Delete
event to store what I needed in an array. In the AfterDelConfirm in
the SubForm I had code to delete a row from the table that the Form
was attached to using information from the array. That worked fine
but when I tried to move to another control on the Form I got the
following error message several times "This operation is not
supported within transactions".

I then decided to scrap that idea and do the required update in a
program that runs in the background.

However, when I read your response I tried it again, adding code bit
by bit to see what was causing me to get the error message. I finally
realized that I needed to get the original row back again from the
Form that I had deleted the row (in the SubForm) from. Once I did
that (in the AfterDelConFirm Event) everything worked as I wanted it
to!

I'm a little confused as to what you did before and are doing now, but
fortunately it's working. Yea!
 
R

RitaG

It seems I spoke too soon (althought I don't get that error message anymore).
I have a breakpoint on the Delete Event and a breakpoint on the
AfterDelConfirm Events. WHen I delete a row in the SubForm, I break in the
Delete Event. However, weh I step debug through it and come to the "End Sub"
I dod not get the Delete Confirmation message not do I break in the
AfterDelConfirm Event.

If I take the breakpoint off the Delete Event, I do get the Delete
Confirmation message but my information that I need from the Delete Event
(that I store in a collection) has no values!

I'm so confused!!!
How can just setting a breakpoint cause the code to act differently?
 
D

Dirk Goldgar

RitaG said:
It seems I spoke too soon (althought I don't get that error message
anymore). I have a breakpoint on the Delete Event and a breakpoint on
the AfterDelConfirm Events. WHen I delete a row in the SubForm, I
break in the Delete Event. However, weh I step debug through it and
come to the "End Sub" I dod not get the Delete Confirmation message
not do I break in the AfterDelConfirm Event.

If I take the breakpoint off the Delete Event, I do get the Delete
Confirmation message but my information that I need from the Delete
Event (that I store in a collection) has no values!

I'm so confused!!!
How can just setting a breakpoint cause the code to act differently?

I ran into this problem recently, and I believe I've demonstrated that
BeforeDelConfirm and AfterDelConfirm don't fire in break mode; at least
not in Access 2002. I haven't seen any confirmation of this from any
other source, though. So I think you'll have to debug your problem
without stepping through the code. If you have no breakpoints, does it
work or fail? If it fails, maybe you'd better sprinkle your code with
Debug.Print statements so you can see what happened after a delete by
checking the Immediate Window.
 
R

RitaG

Good suggestion! I'm using Access 2003 BTW. My code actually does not work
and I did have the thought of putting all the events (there are many) in the
code and placing a breakpoint on them all. I had the thought that there may
be some event that's firing that I'm not aware of.
 
D

Dirk Goldgar

RitaG said:
Good suggestion! I'm using Access 2003 BTW. My code actually does not
work and I did have the thought of putting all the events (there are
many) in the code and placing a breakpoint on them all. I had the
thought that there may be some event that's firing that I'm not aware
of.

FWIW, I have implemented exactly the sort of process you're talking
about -- using the Delete and AfterDelConfirm events to record which
records are deleted -- successfully, so I know that it can work, at
least in Access 2002. Good luck with your debugging, and let me know
how it goes.
 

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