Results 1 to 3 of 3
  1. #1
    alexandervj is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    145

    ParentID doesnt get passed if no children under that parentID


    My forms arent working correctly. 99% sure the reason is the parentID from parent form doesnt show up if there are no records in the child form. It works fine if there are records in the child form which belong to the parentID_FK but clicking the child form from parent when there arent records with that parentID_FK shows no parentID, I checked, but not sure why or what I can do. The onclick event to open the child form from parent form looks like

    OpenForm frm_Child
    where =="[ParentID]=" & [ParentID_FK]

    When you open the child form it should get info from that ParentID_FK and fill in data from the parent table based on the ParentID_FK, which also only works if there are child records with that parentID_FK.

    Is there a better way to open the child form? It works great if there are child records with the parentID. And I half understand why its not working. That open form macro im using is designed to show records that belong to the parentID - if there are no records that belong to the parent then it doesnt show anything, even the parentID.

    Do you have any ideas? Thanks

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    I think one must first align to correct terminology. A 'child form' by definition is inset into a main/parent form. During this inset, in design view of the main/parent form - the wizard is going to ask which is the cross referencing key field common to both.

    So one cannot open a child form unto itself. One opens the main/parent form and thereby the child form also is viewed.

    Please restate what you have.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    It is working. Access can only do what it's told to do. The form opens regardless if there are or are not records.

    Don't open the form if there are no records or else go to new record row and populate the ParentID_FK, assuming the parent record was created and saved. This requires more code.

    Have you considered a form/subform arrangement?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Query that excludes records with no 'children'
    By harris71 in forum Queries
    Replies: 1
    Last Post: 06-19-2013, 07:17 AM
  2. Relating parent and children records
    By Warrior in forum Forms
    Replies: 10
    Last Post: 07-24-2012, 04:57 PM
  3. Replies: 4
    Last Post: 05-30-2012, 08:54 AM
  4. Replies: 1
    Last Post: 03-29-2012, 03:03 PM
  5. Replies: 2
    Last Post: 03-20-2010, 11:08 AM

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