save record in continuous subform before opening child form

G

Guest

I have a Household form that has a continuous subform for all the People that
reside in that household. The continuous subform has a command button that
opens a "child"form where the user can add additional details for that person
(add to their history, etc.)

This works well except when a new person is added to continuous subform,
when the command button is selected, the data added to the continuous subform
has not been added to the database, and is not available for the child form.
This can be avoided by clicking on a different record in the subform prior to
opening the child form, but for ease of use, is there some code I could add
to the command button that would save the current record so that the child
form opens properly?

Code on the command button:
Private Sub Command_Details_Click()
On Error GoTo Err_Command_Details_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "People"

stLinkCriteria = "[People.People ID]=" & Me![People ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command_Details_Click:
Exit Sub

Err_Command_Details_Click:
MsgBox Err.Description
Resume Exit_Command_Details_Click

End Sub
 
J

John Spencer

Try adding the following line of code before the DoCmd.OpenForm

If Me.Dirty = True then Me.Dirty = False

That will force the record to be saved. Which is what clicking on a
different record in the subform was doing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top