Let me ask you a few questions to understand your problem better.
1) Form A - what is the name of the table. (ex. tbl_A)
2) Subform A - same question. (ex. tbl_A1)
3) Form Z - same question. (ex. tbl_Z)
4) You mentioned when you click a button in form A, it will open a
Form Z to add a new record. And when the new record is added it will
automatically add a new record in Subform A. Do I understand it right?
The idea I have in mind is to create an event function to every
control in access forms. For example when you add a record in Form Z (tbl_Z), first it will search if there is an existing record in (tbl_A1) Subform A.
If Yes - it will update it, otherwise/No - it will insert a new record in tbl_A1.
The event function will be an ADODB recordset function filed under Modules. Most of my user defined event functions (such as OnClick, OnOpen, AfterUpdate, etc.) are in one place so it will be reusable in other forms.
Also, based on my experience, when I have user-defined functions in a form,I donot have a subform in it for the reason to easily identify
Let me know if this could work for you.