Update main form change date if subform has been changed

  • Thread starter Thread starter Earl G via AccessMonster.com
  • Start date Start date
E

Earl G via AccessMonster.com

I have a form with two subforms. I need to update the cuurent record in the
main form with a changed date if either of the other subforms have been
changed. I appreciate any help.
 
Earl G via AccessMonster.com said:
I have a form with two subforms. I need to update the cuurent record in the
main form with a changed date if either of the other subforms have been
changed. I appreciate any help.

--
Earl


Message posted via AccessMonster.com

The most elegant way is to do it all in the parent form as shown below.

In the parent form's code module:

Option Compare Database
Option Explicit

Private WithEvents mfrmSub1 As Form
Private WithEvents mfrmSub2 As Form

Private Sub Form_Open(Cancel As Integer)

Set mfrmSub1 = subFormControl1.Form
Set mfrmSub2 = subFormControl2.Form
mfrmSub1.AfterUpdate = "[Event Procedure]"
mfrmSub2.AfterUpdate = "[Event Procedure]"

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)

[changed_date] = Date()

End Sub

Private Sub mfrmSub1_AfterUpdate()

Me.Dirty = True
Me.Dirty = False

End Sub

Private Sub mfrmSub2_AfterUpdate()

Me.Dirty = True
Me.Dirty = False

End Sub
 
Back
Top