Delete record from form and tables

G

Guest

I have used the automated command button to delete records on my "orders"
form. This form has a sub form "OrderDetails"
The code looks like this:
Private Sub Command113_Click()
On Error GoTo Err_Command113_Click

DoCmd.RunCommand acCmdSaveRecord
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command113_Click:
Exit Sub

Err_Command113_Click:
MsgBox Err.Description
Resume Exit_Command113_Click

End Sub
My problem: The delete button deletes the record on my form, but sometimes
leaves it in the "Orders" and "OrderDetails" tables. When I do a customer
orders search, those deleted orders show up. When I click on them to display
the order, they come up blank. I would like them not to show up at all. I
added the "save Record" in the above code, thinking it might help.
 
K

Katrina

Do you have cascading deletions set up in your relations ship from the
Orders table to the OrderDetails button?

If so, then the Details and the orders should both be deleted. If not, set
this up in your relationship.
I would add a "Are You sure you want to delete?" msg box, just to be sure
that they did not hit delete button on accident.


HTH
Katrina
 
G

Guest

Yes, I do have cascading relationships set up. When I go into the Orders
table to delete the record, I am notified that cascading records are being
deleted. It is also deleted from te OrderDetails table. I can also close the
form, search for the record, the Order form opens with the record open, and
the delete works perfectly. Seems like there ought to be an easier way.
 

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