Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Posts
    21

    Unanswered: How make 2nd form open if changes were make on any of 4 forms (main frm and/or 3 subs

    I have the following code in the afterupdate event of the man form. Basically if a change was made on a field on the form a form named "frmRevisionHistory" opens. But if a change was made on any of the 3 sub-forms I want the form "frmRevisionHistory" to open then also. But, and here's the catch, I don't want the form, "frmRevisionHistory", to open more than one time.

    Here's my code for the afterupdate event of the main form:

    Code:
    Private Sub Form_AfterUpdate()
    
        If Me.txtStatus = 1 Then
            Exit Sub
        End If
        
        If Me.chkbxManualSpec = True Then
        
        Dim RS As DAO.Recordset
        Dim tmpRevisionN As Integer
        Set RS = CurrentDb.OpenRecordset("tbl_Revision_History")
        tmpRevisionN = Nz(DMax("[Revision]", "tbl_Revision_History", "[Spec_ID] = '" & [Forms]![frmMatlSpecsHeader]![txtSPEC_ID] & "'"), 0)
    
            RS.AddNew
            RS!Spec_ID = Me.txtSPEC_ID
            RS!HeaderID = Me.txtHeaderID
            RS!Revision = tmpRevisionN
            RS!Changes = "Initial Revision."
            RS!Rev_Date = Date
            RS.Update
    
            DoCmd.OpenForm "frmRevisionHistory", acNormal, , "[Spec_ID] = '" & Me.txtSPEC_ID & "'", acFormEdit, acWindowNormal
            Forms!frmRevisionHistory.SetFocus
            Forms!frmRevisionHistory.txtCHANGES.SetFocus
            
        Else
    
        Set RS = CurrentDb.OpenRecordset("tbl_Revision_History")
        tmpRevisionN = Nz(DMax("[Revision]", "tbl_Revision_History", "[Spec_ID] = '" & [Forms]![frmMatlSpecsHeader]![txtSPEC_ID] & "'"), 0)
    
            RS.AddNew
            RS!Spec_ID = Me.txtSPEC_ID
            RS!HeaderID = Me.txtHeaderID
            RS!Revision = tmpRevisionN + 1
            RS!Changes = "Edit change documentation here."
            RS!Rev_Date = Date
            RS.Update
    
            DoCmd.OpenForm "frmRevisionHistory", acNormal, , "[Spec_ID] = '" & Me.txtSPEC_ID & "'", acFormEdit, acWindowNormal
            Forms!frmRevisionHistory.SetFocus
            Forms!frmRevisionHistory.txtCHANGES.SetFocus
            
        End If
    
    End Sub

  2. #2
    Join Date
    Nov 2011
    Posts
    413
    So use the OnChangeEvent of the subforms and call it from there.

    HTH

  3. #3
    Join Date
    Mar 2008
    Posts
    21
    I don't see an onchange event in the subform properties. Am I missing something?

  4. #4
    Join Date
    Nov 2011
    Posts
    413
    Sorry,I mean't to refer to the Record Change, i.e. the Primary Key or some control.

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The event for a bound form (or subform) is Current:
    Code:
    Private Sub Form_Current()
    
    End Sub
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •