Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Code After Shifting Focus Out of a Subform

Status
Not open for further replies.

CVesta81

Technical User
May 17, 2012
23
0
0
CA
Hello,

I have a form (frmProductsEdit1) and a subform (frmSubPackaging) attached to the form. If any field on the subform changes, I want code to run once the focus is back on the main form that updates the revision date for the specific product code (done by an update query).

The code I am using can be found below, which is being called from the main form:

Code:
Private Sub frmSubPackaging_Exit(Cancel As Integer)

    If Me.frmSubPackaging.Form.Dirty Then
        Call SetPackSpecs(Me.PackSpec)
        DoCmd.OpenQuery "qryUpdateRevisionDate2"
        Forms!frmProductsEdit1!HB_TotalTare = Forms!frmProductsEdit1!frmSubPackaging!HBTotalTare
        Me.Dirty = False
    End If

End Sub

It appears that this code NEVER runs, because from the looks of things the instant the focus leaves the subform, the record saves, with no chance for the Subform to register as "dirty".

What am I doing wrong? Is there some better way to do this? I want to be able to make a change to the subform and then have the code attached run only if there are any changes that previously occurred on the subform.

Look forward to your response.

Thanks so much!

Best Regards,
Chris
 
I'm not sure what all you are attempting to do, but can you use the after update event of the subform? I don't believe I would try to use any code in the main form to accomplish your task.

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top