Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Form Delete events

105 views
Skip to first unread message

Ron Paii

unread,
Jan 3, 2014, 9:24:16 AM1/3/14
to
I am trying to use the Form_AfterDelConfirm event, but it's not firing. Is
this because I am setting Cancel=True in the Form_Delete event?

I am synchronizing 2 subforms, when I delete a record in the master, I need
to delete it's child records. To do this I cancel the delete and handle it
in the Form_Delete event. The problem is I can't requery the subforms in the
Form_Delete event.

Patrick Finucane

unread,
Jan 3, 2014, 3:38:33 PM1/3/14
to
If you canceled the Delete event, there's no need to run the AfterDelete event.

Can you run a Cascade Delete via the relationship window?

David Hare-Scott

unread,
Jan 3, 2014, 5:02:24 PM1/3/14
to
Don't bother, in the relationship between the two tables turn on cascade
deletes.

D

Access Developer

unread,
Jan 4, 2014, 1:58:28 AM1/4/14
to
Ron, in most of the business databases I've worked on, we didn't delete
records -- we either flagged them as inactive or moved them to an inactive
records table. It was important to have history to analyze for planning
purposes.

If you are going to delete, you can delete related records with code, or you
can use Cascade Delete. Even though I rarely used Cascade Delete, I had
nightmares about making some programming error and deleting every record in
the main table and every related record. In instances where the client made
the informed choice to delete records, I first deleted the related records,
then deleted the master/parent record.

You may have deduced that I avoided Cascade Delete as though my history data
depended on doing so (and it did).

--
Larry Linson
Microsoft Office Access MVP
Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

"Ron Paii" <No...@none.com> wrote in message
news:la6h6r$495$1...@dont-email.me...

Ron Paii

unread,
Jan 6, 2014, 1:21:10 PM1/6/14
to


"Access Developer" <accd...@gmail.com> wrote in message
news:bippoj...@mid.individual.net...
This is a scheduling application, the delete is for items no longer needed
after a change order, or items that were never needed. Some related data not
on the scheduling from is moved to another item, so cascade delete will not
work. The form simulates continuous forms with a sub form using 2 sub forms
manually synchronized. When I delete a item, I need to delete it from the
schedule table and update any related tables all within a transaction. I
just can't figure out how to requery the 2 sub forms to show the change.

Access Developer

unread,
Jan 6, 2014, 5:22:21 PM1/6/14
to
Well, all of my paying work in database development with Access was for
clients, and I never knew when some talented analyst in the future would
want to have the historical data to analyze.

I don't know the details of your application, but when you know you need to
update the display, you should be able to Requery both Subforms... from one
of the Subforms, you should be able to reference the other with
Me.Parent!SubformControlName.Requery, then ReQuery the one from which you
are executing code. Your worst problem may be making sure that you Requery
in the correct order.

--
Larry Linson
Microsoft Office Access MVP
Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

"Ron Paii" <No...@none.com> wrote in message
news:laes6n$edj$1...@dont-email.me...

Ron Paii

unread,
Jan 7, 2014, 8:08:40 AM1/7/14
to


"Access Developer" <accd...@gmail.com> wrote in message
news:bj0okq...@mid.individual.net...
> Well, all of my paying work in database development with Access was for
> clients, and I never knew when some talented analyst in the future would
> want to have the historical data to analyze.
>
> I don't know the details of your application, but when you know you need
> to update the display, you should be able to Requery both Subforms... from
> one of the Subforms, you should be able to reference the other with
> Me.Parent!SubformControlName.Requery, then ReQuery the one from which you
> are executing code. Your worst problem may be making sure that you Requery
> in the correct order.
>
I am doing subform ReQuery of the "Child form" but Access does not allow
Me.Requery within the OnDelete event code.

Access Developer

unread,
Jan 7, 2014, 4:25:18 PM1/7/14
to
Are you requerying a record whose deletion triggered the on-delete event...

Is there some other Event which you could use for the VBA ReQuery?

--
Larry

"Ron Paii" <No...@none.com> wrote in message
news:lagu8q$3li$1...@dont-email.me...

Ron Paii

unread,
Jan 7, 2014, 5:26:37 PM1/7/14
to
The user selects an scheduled item and presses the delete key. I cancel the
delete in the on-Delete event procedure. I then check the status to the item
and do the edits and deletes in a transaction. The problem is that Access
does not allow requery to be used while the On-Delete event procedure is
executing. I tried the before and after event, and even the on current, they
either don't fire or give the same error.

"Access Developer" <accd...@gmail.com> wrote in message
news:bj39lp...@mid.individual.net...

Ulrich Möller

unread,
Jan 7, 2014, 5:34:07 PM1/7/14
to
Hi Ron,

perhaps you can decouple the delete transaction from the client delete
request?
Start a timer with a short delay in the form delete event and set a form
global flag which signals a 'delete pending request'. After that,
handle your transactions in the timer event and reset the flag. Prevent
any re-entrance!
It is ugly i know, but could be a workaround.

Ulrich



Access Developer

unread,
Jan 7, 2014, 7:17:37 PM1/7/14
to
<CHUCKLE> Workarounds make the world go around, Ulrich. Even if they are
sometimes a little "ugly".

--
Larry Linson
Microsoft Office Access MVP
Co-Author, Microsoft Access Small Business Solutions, Wiley 2010

"Ulrich M�ller" <knob...@usenet.arcornews.de> wrote in message
news:lahvd0$pea$1...@dont-email.me...

Ron Paii

unread,
Jan 8, 2014, 1:49:28 PM1/8/14
to


"Ulrich Mᅵller" <knob...@usenet.arcornews.de> wrote in message
news:lahvd0$pea$1...@dont-email.me...
Thanks Ulrich. I was thinking about a flag and timer but was hoping for
something cleaner.

Ron Paii

unread,
Jan 22, 2014, 8:04:34 AM1/22/14
to


"Ron Paii" <No...@none.com> wrote in message
news:lak6jr$ek3$1...@dont-email.me...
>
>
> "Ulrich Möller" <knob...@usenet.arcornews.de> wrote in message
The timer event works. In the sub form's on delete event it turn on the main
form's timer event by setting the time to 1 second. In the timer event I set
it back to 0. One second after the delete the 2 sub forms are recalculated.

0 new messages