Results 1 to 4 of 4
  1. #1
    wayneb777 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2015
    Posts
    1

    combining the records of 3 tables in a specific order


    i have 3 tables with different fields in them except for two, account# and charge#. i need to combine in such a way that the first output row would have the table 1 fields, the next row table 2 fields and the next row table 3 fields for each account/charge number like so...


    row 1: facility#, lic#, account type
    row 2: diag#, diag description
    row 3: proc#, proc description
    row 4: facility#, lic#, account type for the next account/charge combination
    row 5:...

    row 4 would begin for the next account/charge.

    i'm not sure how to output the data sorted in this way.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Do NOT use embedded spaces or non-alphanumeric characters(#) in your field and object names. It will save you many syntax errors.

    I suggest you
    -tell us WHAT this data represents in simple English business terms, and
    -show us some sample data to help us understand your situation.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    there is no 'row order' in access...its just how the table is currently sorted.
    if your
    row 1: facility#, lic#, account type
    row 2: diag#, diag description
    row 3: proc#, proc description

    are all related, then I would add an extra field in all 3 tables, say, "batch"
    so then, you can just throw all tables together, then sort the way you want.

    row 1: facility#, lic#, account type, 1
    row 2: diag#, diag description, 1
    row 3: proc#, proc description, 1
    row 4: facility#, lic#, account type, 2
    row 5: diag#, diag description, 2


  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Not seeing account# and charge# fields in the example data. Do they make up a compound PK/FK?

    Assuming the 3 tables are something like: Facilities, Diagnoses, Procedures - think will need a UNION query.

    SELECT [account#], [charge#], [facility#] AS somename, [lic#] AS somename, [account type] AS AccountType, "fac" AS Source, 1 AS Seq FROM Facilities
    UN ION SELECT [account#], [charge#], [diag#], [diag description], Null, "diag", 2 FROM Diagnoses
    UN ION SELECT [account#], [charge#], [proc#], [proc description], Null, "proc", 3 FROM Procedures;

    Now use that query as source for subsequent queries and report. Since the Source field has values that happen to alphabetically fall into the order you want, the Seq field could be eliminated.

    Advise no spaces and special characters/punctuation (underscore is exception) in naming convention.




    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. Union Query Order By Specific Row Values
    By Dormie in forum Queries
    Replies: 3
    Last Post: 02-18-2015, 10:42 AM
  2. Replies: 1
    Last Post: 04-29-2014, 12:20 AM
  3. Replies: 6
    Last Post: 12-07-2012, 07:57 AM
  4. Replies: 1
    Last Post: 10-21-2012, 11:31 PM
  5. Replies: 4
    Last Post: 04-12-2012, 02:38 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