Link to home
Start Free TrialLog in
Avatar of marku24
marku24Flag for United States of America

asked on

Saving records on a subform from a parent

I have a parent form (frmParent) that has a subform embedded in it (frmSub).  I would like to create a Save command on the parent that will save the records on the sub as if it was actually on the subform.  I am having a problem with the context.  I am using Forms!frmParent!frmSub.DoCmd.Save but get an error.  Is there something more to this?  ~ Thanks
Avatar of tbsgadi
tbsgadi
Flag of Israel image

Hi marku24,

As soon as you go from the subform to the main form the records are automatically saved.

Gary
Avatar of thenelson
thenelson

DoCmd.Save acForm, "frmSub"
tn,

Doesn't that just save the Object?
Avatar of marku24

ASKER

That didn't work.  It's telling me the object isn't open so I used the full location of "Forms!frmParent!frmSub" but it still says it's not open when I am sure it is open.  
ASKER CERTIFIED SOLUTION
Avatar of thenelson
thenelson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marku24

ASKER

Thanks - Doesn't that just mark the form as "not dirty".  Does it also save the form?
It forces the save - otherwise the form would still be "dirty".
Avatar of marku24

ASKER

Interesting.  It seemed to have work.  Thanks
Let's go back to the beginning...

As tbsgadi stated, the records in the subform get saved when you navigate to another record, close the form or the form loses the Focus.
So first can you tell us why you want to save the record manually, when they are saved automatically by default?

<Me.frmSub.Form.Dirty = False>
As thenelson posted, this does save the *record*.
Then you asked:
<Does it also save the form?>
Now you want to save the *Form* itself *AND* the *record*?

Saving the Form itself and saving the records are two different things.
Furthermore just doing data entry in a form/subform, does not change the form itself (does not change the forms Design), Thus, saving the form is not even applicable here.
So, again, I do not understand exactly what you are asking for?

For the record, can you clearly state What your ultuimate goal here is, and Why?

Thanks

JeffCoachman
Avatar of marku24

ASKER

From a parent I have data being entered on a subform based on certain options being selected from the parent.  When the data would write into the subform it would remain in "edit" mode and show the pencil on the left have side of the record.  If I click on a SAVE button within the subform the record would be committed and saved.  I don't want to manually click on that button.  I want to trigger the save and commit the record from the parent.  If I try and scroll through the parent records while the sub is still in edit mode, the parent and sub become out of sync.
OK,

If you have a solution that works now, then roll with it.
You're welcome.  Glad to help and thank you very much for the points with "A" grade!

Happy Computing!

Nelson