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

SteveL

Registered User.
Local time
Yesterday, 22:46
Joined
Dec 3, 2004
Messages
60
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
 

Users who are viewing this thread

Back
Top Bottom