Results 1 to 2 of 2
  1. #1
    Flippa is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    1

    Split Record Query

    Hi all,



    I have a table that lookes like the "from" table in the attachement and would like to run a query to arange the data to look like the "to" table in the attachment.Attachment 5531

    As you can see I have added a field for year and cost and created a record for each instance from the original table where there was money spent in a year.

    Can you give me some advice to achieve this?

    I suspect that it will require some VB code.

    Thanks

    Flip

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No code, a UNION query:

    SELECT AssetID, Description, BudgetSource, 2011 AS TheYear, [2011] AS Cost
    FROM TableName
    WHERE [2011] Is Not Null
    UNION ALL
    SELECT AssetID, Description, BudgetSource, 2012 AS TheYear, [2012] AS Cost
    FROM TableName
    WHERE [2012] Is Not Null

    Note that "Year" is not a good field name, as it can conflict with the Year() function.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 10
    Last Post: 03-28-2011, 08:57 AM
  2. Replies: 2
    Last Post: 01-27-2011, 08:04 AM
  3. Crosstab Query / Split Database
    By ksmith in forum Programming
    Replies: 2
    Last Post: 11-18-2010, 11:55 AM
  4. Split data by using query
    By lamkee in forum Queries
    Replies: 1
    Last Post: 11-07-2010, 11:23 AM
  5. Split a string for use as query parameters.
    By Hobbes29 in forum Forms
    Replies: 3
    Last Post: 06-27-2010, 04:39 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