Results 1 to 7 of 7
  1. #1
    bsmith is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    So. Cal.
    Posts
    7

    UNION query

    Re: https://www.accessforums.net/access/...tml#post239206

    I'm a newbie and I have a similar problem. Mine is exactly as the following:

    ID
    Parent
    Address
    Child1
    Child1DOB
    Child2
    Child2DOB
    Child3
    Child3DOB
    1
    Sarah 1st St. F
    9/2/2010
    E
    8/1/2012
    B
    1/31/2014
    2
    Mary 9th Cr. C
    3/15/2011
    A
    1/26/2013
    D
    5/6/2014
    Sorted by Child DOB (Month first and then Day), Printed in the Report as:
    Parent Child
    DOB
    Mary A
    1/26/2013
    Sarah B
    1/31/2014
    Mary C
    3/15/2011
    Mary D
    5/6/2014
    Sarah E
    8/1/2012
    Sarah F
    9/2/2010

    I was trying to work with the Query Union function, but so far I'm just not getting it. Sorry :~(



    Any help is much appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Your data is not normalized. For some reason I cannot type UNION in the example query. Replace ______ with UNION.

    SELECT ID, Parent, Address, 1 AS ChildNum, Child1 AS Child, Child1DOB AS DOB FROM tablename
    ______ SELECT ID, Parent, Address, 2, Child2, Child2DOB FROM tablename
    ______ SELECT ID, Parent, Address, 3, Child3, Child3DOB FROM tablename;
    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.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    And given the likelihood that not everyone has the max number of kids I'd filter each, like:

    SELECT ID, Parent, Address, 2, Child2, Child2DOB FROM tablename WHERE Child2 Is Not Null
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    bsmith is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    So. Cal.
    Posts
    7
    Great! I'll give that a shot tonight and let you guys know how things go.

  5. #5
    bsmith is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    So. Cal.
    Posts
    7

    Smile

    Thanks June7 and pbaldy! It worked! I did some extra stuff, but I could not have done it without your help. On a side note, I changed the pbaldy's suggestion into "SELECT ID, Parent, Address, 2, Child2, Child2DOB FROM tablename WHERE Child2DOB Is Not Null" in case a child's name was entered and not the birthdate.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You don't want those children listed if the DOB is not entered? List them and you know data is missing.
    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.

  7. #7
    bsmith is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    So. Cal.
    Posts
    7
    It's all good.

    Some parents will provide the child name and DOB, but some think the DOB information should not be shared within our group. So far the way I have it now, this solves it and gives the results for kids and kids with DOB, but not blank fields for people with 1 kid (or less).

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

Similar Threads

  1. Union Query
    By scoe in forum Queries
    Replies: 8
    Last Post: 08-06-2013, 06:02 PM
  2. Union Query
    By carymehome in forum Queries
    Replies: 6
    Last Post: 06-14-2013, 12:42 PM
  3. Replies: 8
    Last Post: 10-22-2012, 07:43 PM
  4. Union Query Help
    By pmp in forum Queries
    Replies: 4
    Last Post: 10-28-2011, 06:41 AM
  5. Help with a Union Query
    By Bear in forum Queries
    Replies: 12
    Last Post: 08-14-2011, 05:12 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