My thought would be put the code on the subforms cancel button on_click event.
Would be something like:
Forms!Mainform!ControlName = False
DoCmd.Close acForm, Mainform
DoCmd.Close acForm, Me.Name
Without knowing exactly how your forms are handled on close, field names and form names it’s a...