saving record before moving between forms

B

barrynichols

morning,

i have a command on one form which opens a second form, creates a new
record with a field copied from the first form to the second.

however, when i click through without saving the first form I run into
problems. is there a line of code I can add to the below to save the
current record before actioning the command?


Private Sub Command114_Click()
On Error GoTo Err_Command114_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_Assessment"

stLinkCriteria = "[Visit ID]=" & Me![VisitID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Forms![frm_Assessment]![Shopper ID] = Me![ShopperID]

Exit_Command114_Click:
Exit Sub

Err_Command114_Click:
MsgBox Err.Description
Resume Exit_Command114_Click

End Sub

Thanks

Barry
 
A

Allen Browne

Add:
If Me.Dirty Then Me.Dirty = False

If you prefer:
RunCommand acCmdSaveRecord
 

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