Hi everybody
I have main form and a sub form on it and sub form data source is query, I am trying to figure out if i can save my main form with subform in one save command button, also it should not irritate me by asking to save each time i move my cursor to subform.
I have following code ready for main form and i want to tailor it to include my above requirement.
I hope i make sense in above details.
I have main form and a sub form on it and sub form data source is query, I am trying to figure out if i can save my main form with subform in one save command button, also it should not irritate me by asking to save each time i move my cursor to subform.
I have following code ready for main form and i want to tailor it to include my above requirement.
Code:
Option Compare Database
Private Sub BtnSave_Click()
saved = True
DoCmd.RunCommand (acCmdSaveRecord)
Me.BtnSave.Enabled = False
saved = False
End Sub
Private Sub CmdNew_Click()
DoCmd.OpenForm "frmAddnewEntry"
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Response As Integer
If saved = False Then
Response = MsgBox("Do you want to save the changes on this record?", vbYesNo, "Save Changes?")
If Response = vbNo Then
Me.Undo
End If
Me.BtnSave.Enabled = False
End If
End Sub
Private Sub Form_Dirty(Cancel As Integer)
Me.BtnSave.Enabled = True
End Sub
Private Sub txtEntryNo_AfterUpdate()
Me.Recordset.FindFirst "EntryNo = " & Nz(txtEntryNo, 0)
End Sub
I hope i make sense in above details.