By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Delete Record In Parent Form

100+
P: 135
HI,

When a new record is opened in a main form / sub form, how do I prevent the main form from saving data if the sub form is not filled? Or how do I delete the current main form record if the sub form is not filled?
Dec 14 '07 #1
Share this Question
Share on Google+
7 Replies


Rabbit
Expert Mod 10K+
P: 12,366
HI,

When a new record is opened in a main form / sub form, how do I prevent the main form from saving data if the sub form is not filled? Or how do I delete the current main form record if the sub form is not filled?
You can't prevent the main form from saving data because there needs to be an existing main record for a sub record. You could have the form delete the offending records when it closes though.
Dec 14 '07 #2

100+
P: 135
You can't prevent the main form from saving data because there needs to be an existing main record for a sub record. You could have the form delete the offending records when it closes though.
What is the code/procedure for deleting the offending records? I've searched (googled my googler to death), but all I find is info on delete object or a delete queries which seem to be to broad.

Thanks for responding.
Dec 14 '07 #3

Rabbit
Expert Mod 10K+
P: 12,366
What is the code/procedure for deleting the offending records? I've searched (googled my googler to death), but all I find is info on delete object or a delete queries which seem to be to broad.

Thanks for responding.
Not much code. Just set up the delete query with a subquery condition and then use DoCmd.OpenQuery.
Dec 14 '07 #4

100+
P: 135
Not much code. Just set up the delete query with a subquery condition and then use DoCmd.OpenQuery.
Thanks!

Not to be pushy but... how do I word the the subquery so it will delete the "selected current" record? Also, I have the problem where when I do try to delete a record from the main form (using the archaic click on the edit menu and delete) it won't let me because I have a related record in another table (the sub form table). So I would have to delete related records as well. Sorry, I usually just search and search until I find code/explanation/criteria that will work for my application. I'm not to hot at putting the language together from scratch. Kind of stuck learning as I go... know any great books on access/vb/vba? = )
Dec 14 '07 #5

Rabbit
Expert Mod 10K+
P: 12,366
Thanks!

Not to be pushy but... how do I word the the subquery so it will delete the "selected current" record? Also, I have the problem where when I do try to delete a record from the main form (using the archaic click on the edit menu and delete) it won't let me because I have a related record in another table (the sub form table). So I would have to delete related records as well. Sorry, I usually just search and search until I find code/explanation/criteria that will work for my application. I'm not to hot at putting the language together from scratch. Kind of stuck learning as I go... know any great books on access/vb/vba? = )
You don't word it to delete selected record. You have it do a one-time delete when the form closes and delete everything that doesn't have a subform record.

If you set up the relationships with the Enforce Relationship and Cascade delete checked, you won't have to go through that process. But you don't want to delete that record anyways right? It has a subform record, you only want to delete the ones without a subform record.

I don't know any books, i learned as I went as well.
Dec 14 '07 #6

100+
P: 135
You don't word it to delete selected record. You have it do a one-time delete when the form closes and delete everything that doesn't have a subform record.

If you set up the relationships with the Enforce Relationship and Cascade delete checked, you won't have to go through that process. But you don't want to delete that record anyways right? It has a subform record, you only want to delete the ones without a subform record.

I don't know any books, i learned as I went as well.
OK, I'll give it a go. Thanks Rabbit, and your right... I don't want the sub form records zapped. Just wondered how it's done.
Dec 14 '07 #7

Rabbit
Expert Mod 10K+
P: 12,366
Good luck, let us know if you have any trouble.
Dec 14 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.