Results 1 to 6 of 6
  1. #1
    chauncey274 is offline Novice
    Windows 8 Access 2003
    Join Date
    Oct 2015
    Posts
    5

    Combining rows in access?

    Hello Forum!

    I've tried searching for a solution to this but have found nothing so far and to be honest I'm not really sure how to describe what I'm searching for in just a phrase, so I'm at a loss.

    I've been thrown in to an access database at work with little experience thought I'm getting my feet wet and I'm stuck. Here is a screenshot of my current table:
    Click image for larger version. 

Name:	Capture.jpg 
Views:	14 
Size:	219.2 KB 
ID:	22439
    So column "block name" is an item inside an autocad drawing. The "File" column is the actual autocad drawing that the block is in. There are numerous blocks inside each of the drawings, some blocks are in drawings and aren't in others etc.

    The rest of the columns are pieces of information inside the block on that row. Some blocks have alot of these, some have one.

    I need a way to get all of the attributes to go up in to one row per drawing, regardless of the block. each column should only have one field filled in per drawing, so I'm not worried about one drawing having the same block twice.



    I hope I've described what I'm trying to do accurately.

    Thanks in advance for any and all help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    This "each column should only have one field filled in per drawing" makes no sense. Did you mean "each row"?
    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
    chauncey274 is offline Novice
    Windows 8 Access 2003
    Join Date
    Oct 2015
    Posts
    5
    Yes thank you. I want every row that has another row with a matching "file name" column to all combine in to one row. I will post a good example tomorrow.

    Thank you

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,830
    So are you saying that for example the JIPCABLENO column is either blank or only ever has DMPX-XXA in it - at least at the drawing level?

    The problem is your data is not normalised so you are going to need a pretty complex query

    Intitially try

    Code:
    SELECT DISTINCT FileName, JIP1CABLENO
    FROM myTable
    WHERE JIP1CABLENO IS NOT NULL
    if this gives the correct result, save it as qryJIP1CABLENO

    write and save another query for the next column and so on, until all columns are done

    Next, write a different query - simply

    Code:
    SELECT DISTINCT FileName
    FROM myTable
    and save it as qrymaster

    finally a query to put it all together

    open the query designer and drag qrymaster into the grid, then drag qryJIP1CABLENO onto the grid and make a join between filename in the qrymaster and filename in qryJIP1CABLENO. Right click on the join and select option 2 (include all records from qrymaster and only those from qryJIP1CABLENO where they are equal - or words to that effect). Then drag filename in qryMaster and JIP1CABLENO from qryJIP1CABLENO to the grid at the bottom.

    Now click on the SQL button to view the sql generated - it should look something like

    Code:
    SELECT qryMaster.Filename, qryJIP1CABLENO.JIP1CABLENO
    FROM qryMaster LEFT JOIN qryJIP1CABLENO ON qryMaster.FileName=qryJIP1CABLENO.FileName
    All set? run the query - does this give the result you expect for these two columns? I would expect to see all the filenames and DMPX-XXA in the JIP1CABLENO column or blank where this filename does not use the JIP1CABLENO column.

    If all OK, return to the query design and drag qryJIP1DCVSCABINET onto the grid, make a join between qryMaster and this query as before, right click, select option 2 and then drag JIP1DCVSCABINET to the grid below (no need to do the filename, you've already got that).

    Now repeat for each of the other queries

    This should produce what you want

  5. #5
    chauncey274 is offline Novice
    Windows 8 Access 2003
    Join Date
    Oct 2015
    Posts
    5
    Quote Originally Posted by Ajax View Post
    So are you saying that for example the JIPCABLENO column is either blank or only ever has DMPX-XXA in it - at least at the drawing level?

    The problem is your data is not normalised so you are going to need a pretty complex query
    Correct. JIPCableNO is either blank or has that designation filled in. I'm going to fill in that cable number from information already in the database, but I have to get it set up first.

    I'll go through and try your method right now. I was just hoping there was an easier way. That's how autocad fills in the information when you export data so there's not much I can do on that end.

    Thanks.

  6. #6
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    For there to be 1 row per drawing; there must be 1 value per field/column. Are you sure there is always only 1?....looking at your data it appears very possible there could be data in the same field in different rows.... how then would that be presented?

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

Similar Threads

  1. combining records(rows)
    By pradeep.sands in forum Queries
    Replies: 4
    Last Post: 06-13-2013, 12:19 PM
  2. combining rows.. again
    By jerryb in forum Access
    Replies: 16
    Last Post: 05-03-2012, 08:34 PM
  3. Combining rows in query?
    By rev in forum Queries
    Replies: 2
    Last Post: 04-23-2012, 08:47 AM
  4. Combining rows
    By Bing in forum Queries
    Replies: 1
    Last Post: 06-09-2011, 12:54 PM
  5. Combining columns into rows
    By steeveepee33 in forum Queries
    Replies: 5
    Last Post: 04-30-2009, 09:18 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