Delete records from form and tables (Third Post)

R

Ron Weaver

Occasionally while entering an order on my Orders form/OrderDetails subform
I need to delete the current record. I thought my delete command would
delete the record from the form and both tables. The record is deleted from
the form, but not from the tables. My tables are set to cascade on delete.
Currently to delete a record from the tables, I first have to close the
Orders form, go to my search form, and reopen this record in the Orders form.
The delete command then deletes the record from both tables. I have tried
using 'Me.Refresh' as the first line of code in my delete code, with no
results.
Thanks for any help on this.
 
A

Allen Browne

Ron, you say:
The record is deleted from the form, but not from the tables.

That makes no sense to me. Forms do not store data, is it is impossible to
delete a record from a form (where was not stored anyway) and yet still have
it stored in a table. I don't think you are taking about filtering the form
so that the record doesn't show, so I have no idea what you are talking
about.

If you do have cascading delete between your Orders table and OrdersDetails
table, and you want to create your own Delete button on the form (instead of
just using the one Microssoft provides on the toolbar), you could put
something like this in its Click event procedure:

If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord then
RunCommand acCmdDeleteRecord
End If
 
G

G. Vaught

Are you using the built in command button that will delete records or are
you using code that you wrote? If it is the latter, then it probably is your
code.
 
R

Ron Weaver

Allen
I meant that when I hit delete, the form went blank, but the records were
still in the tables. I just put your code in the click event of my delete
button, but it still does the same.
Thanks
 
R

Ron Weaver

Something I just discovered: The delete works perfectly until I enter
something into the subform, OrderDetails, where I enter the equipment.
 
A

Allen Browne

Something else is happening, Ron.

Take it one step at a time. Confirm the entry is, in fact being saved, by
looking in the table after you enter the record. Then confirm that the
record is gone after deleting it. Then track down what other interferring
process is messing it up.
 
R

Ron Weaver

yes, I have done that, confirming the entry was saved, deleted. I'm in the
tracking down process. I believe it has something to do with the subform.
Thanks
 

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