DoCmd.Save - Form and Subform (1 Viewer)

jills

New member
Local time
Today, 12:45
Joined
Oct 8, 2006
Messages
1
Hi all,

I have a form (Record Source = Report_TBL). I've brought in a subform (Record Source = Patient_TBL). I linked the 2 on the field PID.
I've added a command button (Submit).
OnClick for the Submit button I've added in the Event Procedure

Private Sub cmdSubmit_Click()

DoCmd.Save

End Sub

It only saves the data I've put in for the subform.

Can anyone give me any information on how to save all the information from both forms?

Thank you so much for your help!
Jill
 

RuralGuy

AWF VIP
Local time
Today, 11:45
Joined
Jul 2, 2005
Messages
13,826
The SubForm record is automatically saved when you move the focus back to the MainForm. The MainForm record will automatically be saved when you move to another record or close the form.
 
R

Rich

Guest
The Main form record is saved as soon as you enter the subForm
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:45
Joined
Feb 19, 2002
Messages
43,257
DoCmd.Save saves the current object which in this case is a form. It does NOT save data. The data for the subform is automatically being saved when focus moves back to the main form. If you want to add a button to save the main form record, the correct statement is:

DoCmd.RunCommand acCmdSaveRecord

This save button isn't necessary since Access will save the data if you move the record pointer, move focus to the subform, or close the main form among other situations.
 

Users who are viewing this thread

Top Bottom