Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Parent Form and Sub Form Change Focus
Todd Clapp 
    
12 months ago
I have a parent form (receiveF) and a continuous subform (receiveListF) where users can enter inventory items. I'm trying to add functionality to the form that asks the user if they want to save the changes to the form or undo the changes. Richard has a great video on this topic with a single form that I used but it opens when the user tabs from the parent form to the subform. Here is some code that I last tried that still does not work:

DetailsPrivate Sub Form_Unload(Cancel As Integer)
    ' Only check for unsaved changes if not switching to subform
    If Me.Dirty And Not (Me.ActiveControl Is Me.ReceiveListF Or Me.ActiveControl.Parent Is Me.ReceiveListF) Then
        Call Form_BeforeUpdate(Cancel)
    End If
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
    ' Ensure the prompt only triggers when actually closing
    If Not Me.NewRecord And Me.ActiveControl.Parent Is Me.ReceiveListF Then Exit Sub

    Dim response As Integer
    response = MsgBox("Do you want to save your changes?", vbYesNoCancel + vbQuestion, "Confirm Save")

    Select Case response
        Case vbYes
            ' Proceed with saving
        Case vbNo
            Me.Undo ' Undo changes made to the form
        Case vbCancel
            Cancel = True ' Cancel the close action and keep the form open
    End Select
End Sub


Any idea how to stop the BeforeUpdate msgbox from running if the user tabs to a subform? Thanks in advance for your help.
Jeffrey Kraft  @Reply  
      
12 months ago
This issue (to me at least) is the focus has changed from the Parent form to the Sub Form.  Another thing to consider is the subform continuous or single record.   Maybe a way to set up a "Flag" to let Access know your not not moving to a new record. I throwing something out there.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 5:17:21 AM. PLT: 1s