Results 1 to 5 of 5
  1. #1
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    Shall Stop Orphan Records in SubForm!

    Hi

    The main form record set moves to next without having data in the Subform fields even though clicked for Required "Yes"



    how to prevent the main form to go new record until subform fields are filled up?

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    More than one way. Assuming you're filling in the main form first, when a key field exists on both forms and data is entered in that field of the main form, the AfterUpdate event of the control could populate a related subform field. If fields are set to 'required' at the table level, Access will complain when you try to move off of the record using main form navigation. You can also put validation messages at the table level. This method requires table design modifications for even simple things like changing the message, so it's probably not a popular method but it may be the only one that will prevent Access from moving off the record without a bunch of customization.

    You can also use form level validation by checking that the subform controls have values when the main form does, in the main form BeforeUpdate event. However, I can't recall if you can prevent navigation using the built in navigation controls and the event may fire if the user clicks on the subform as the main form will lose the focus. They'd get an annoying message when attempting to do exactly what is supposed to be done. I know that one way is to remove the built in nav controls and substitute your own. Then you can check for required fields and prevent a record move.

    The situation you're describing isn't really a flaw if that's what some think (at least I think not) as the notion of creating a main record without child records isn't always a bad thing. Having a main entity (such as a customer) without related records wouldn't always violate data integrity rules.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    Thanks for the such a wonderful explanation. Thanks

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    np. hope it helps.
    Nice when somebody is appreciative.

  5. #5
    cap.zadi is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    My Pleasure.

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Stop Subform From Loading
    By Oxygen Potassium in forum Access
    Replies: 4
    Last Post: 07-20-2017, 07:53 AM
  2. What makes a subform stop working?
    By snowboarder234 in forum Forms
    Replies: 5
    Last Post: 06-01-2016, 03:00 PM
  3. Stop the introduction of records
    By azhar2006 in forum Forms
    Replies: 27
    Last Post: 02-14-2014, 03:42 PM
  4. Replies: 0
    Last Post: 12-20-2010, 12:35 PM
  5. Stop subform from creating record
    By eww in forum Forms
    Replies: 2
    Last Post: 09-16-2010, 02:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums