Delete REcord isnt Available

  • Thread starter RedHeadedMonster via AccessMonster.com
  • Start date
R

RedHeadedMonster via AccessMonster.com

I have a button with the following code:

DoCmd.RunCommand acCmdDeleteRecord

When you click it, I get the annoying error that Delete Record isnt available.
The form only allows the users to view current records so its not a case of a
new record.

Im thinking it has something to do with my AfterUpdate event....Which creates
a transaction log of changes.

How do I turn off my afterUpdate code in the case of the delete record button
being clicked?

Thanx!
RHM
 
J

Jeanette Cunningham

The most common reason is that deleting that record is not possible.
Does the form use an updateable record source?
Does deleting that record violate referential integrity? - meaning that
perhaps that record is part of a relationship between a parent and child
record.
All child records (for a parent record) must be deleted before the related
record can be deleted.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
R

RedHeadedMonster via AccessMonster.com

Ok none of that applies. I seriously thing it has to do with the
beforeupdate and afterupdate events. Is there a way to suppress these events
if the delete button is clicked?

Jeanette said:
The most common reason is that deleting that record is not possible.
Does the form use an updateable record source?
Does deleting that record violate referential integrity? - meaning that
perhaps that record is part of a relationship between a parent and child
record.
All child records (for a parent record) must be deleted before the related
record can be deleted.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I have a button with the following code:
[quoted text clipped - 16 lines]
Thanx!
RHM
 
B

Bob Quintal

Ok none of that applies. I seriously thing it has to do with the
beforeupdate and afterupdate events. Is there a way to suppress
these events if the delete button is clicked?
At the top of the form's code module, Just below the Option Explicit
and Option Compare statements, add
Dim bDeleteClicked as Boolean

in the form's Current event add
bDeleteClicked = False

at the top of your before and after upddate events add
If bDeleteClicked Then Exit Sub

and in your delete button's click event put
bDeleteClicked = true



Jeanette said:
The most common reason is that deleting that record is not
possible. Does the form use an updateable record source?
Does deleting that record violate referential integrity? - meaning
that perhaps that record is part of a relationship between a
parent and child record.
All child records (for a parent record) must be deleted before the
related record can be deleted.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I have a button with the following code:
[quoted text clipped - 16 lines]
Thanx!
RHM
 

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