A family of Microsoft relational database management systems designed for ease of use.
The issue of course is that the one main form, and the one record?
You can easy check if the form is "dirty" and prompt as such.
However, the sub form is more difficult, since there are MANY records, and the me.dirty for the sub form ONLY applies to the current row the user is on. In other words, like all forms, be it the main form, or the sub form? They are all dealing with ONE record at a time.
So, if the user is editing a record in the sub form, and moves on to the next record, then the previous record is saved, and hence the sub form is not going to show dirty anymore.
So, all forms work with "one" record, and one record at a time. As a result, there not really a practical way to prompt the user to save both parent record, and the "many" child records that may well have been updated.
Worse yet, if the user edits 2 or 3 sub form records, then they are all saved, and now you edit the main record, and answer NO to edit changes. Thus, you not saving those edits to the main form, but the child rows will have been saved.
As a result, you can't really have a single save prompt, and NOT save all edits in one shot due to the sub form. So, this so called "design" pattern does not work with Access and bound forms.
Some ideas?
Well, in place of a nag save prompt, you disable all controls, and provide a edit button. That way, accidental changes can't be made. And, you can when the user hits edit (and enable all controls - include sub form), then you can log that fact in a log table. Now, the user might not do any edits AFTER hitting the edit button, but at least users can't edit by accident, and hitting the edit button can log that fact.
Another idea? Well, you adopt a accounting type of "posting" process. so, as a user edits the records, then you have a single field in the "main" form that is a posting flag. User can thus edit records, and thus you build up a posting list of records to "post". For example, here is a classic accounting posting page in which a single check or donation example is distributed to multiple accounts. However, we don't want to save the data UNTILL such time the donation amount matches the amounts for multiple accounts. due to the above sub form issue, we could not test/check/prevent a save of the form + sub form in which the balance of amounts in the sub form MUST match the 1 single donation amount in the parent form.
So, we let the user start a "batch". The user enters donation amounts, and then in sub form enters the distriputed amounts that must total up to the one parent reocrd. However, they are fee to edit, free to add new donations (and sub form distributled amounts). But, at end of day, they then hit a post button, and it checks if the totals in the one parent record matches the total in the child distroubtion amounts. If the totals don't match, then the one records "ok balance matched" flag is not set.
In effect, that one "flag" in the main record MUST be set to true for the information to be valid.
Hence, the Access screen looks like this:
So, in above, the user entered $50. And I did not want to save the form UNLESS the total on the right side matches. But, with the main form + sub form, then I can't control the "whole thing" in one save operation. So, I let the user edit all day long. But, at end of day, the post (close) batch will run some VBA code that checks the main total record (one donation), and then checks the child records. If the totals don't match, then I don't set nor allow the posted date field to be updated. In effect, the result is the SAME as if I had the ability in access to save a master + child set of data in one operation. Since we don't, then adding the concept of a posting batch solves this issue.
As noted, in your case? Just add a edit button to the form, and then on for load, you can set allow edits = false, and the user's can't make accidental changes. so, don't try to build a save prompt, since it can't work for a master/child (subform) setup. But, what you can do is not allow edits when the form loads, and hence accidental changes can't occur until they hit some "enable" button.
So, say like this:
So, the form editing is disabled until you hit the edit button, and it turns green.
So, don't try to prevent a save, but prevent a edit in the first place, and that way you eliminate accidental edits.