Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Running Code After Shifting Focus Out of a Subform

Running Code After Shifting Focus Out of a Subform

Running Code After Shifting Focus Out of a Subform


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:


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,

RE: Running Code After Shifting Focus Out of a Subform

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.

Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close