Results 1 to 6 of 6
  1. #1
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115

    Combining multiple rows into a single row for data entry

    Hi. I have 2 tables the first is product and the second is product properties (1 to many from product). There are 2 properties that I am interested in per product. Each property has a name (sname) and a value (sValue). I have a query that returns the data I want but it creates 2 rows per product (1 for each property):



    SELECT p.[product reference], p.[short description], p.nStockOnHand, v.sname, u.sValue
    FROM (product AS p LEFT JOIN userdefinedproperties AS u ON p.[product reference] = u.scontentID) LEFT JOIN variable AS v ON u.nVariableID = v.[nID]
    WHERE ((((v.sname)='Cut Fat Quarter Stock Level')) AND (p.[product reference] NOT LIKE '*!*'))
    ORDER BY p.[product reference], v.nID;

    This returns (as an example):
    product reference short description nStockOnHand sname sValue
    1027 Deco Flowers Apple Rings 1145-G 55 Cut Fat Quarter Stock Level 12
    1027 Deco Flowers Apple Rings 1145-G 55 Fat Quarters on Bolt 22
    1038 Deco Flowers Pistachio Boxes 1146-G 3 Cut Fat Quarter Stock Level 1
    1038 Deco Flowers Pistachio Boxes 1146-G 3 Fat Quarters on Bolt 2


    I would like to create a view of the data that shows both properties for a product on the same row:

    Product Reference, Short Description, nStockOnHand, sname, SValue , sname, sValue
    1027 Deco Flowers Apple Rings 1145-G 55 Cut Fat Quarter Stock Level 12 Fat Quarters on Bolt 22


    Please could someone help me adjust the query.

    Not sure if this matters BUT: I would want to be able to go into the datasheet view and be able to change the values in the 2 properties fields and have the changes reflected in the DB (as I can now with my query)

    Many thanks for you help

    Tony

  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,929
    I don't think any query to do what you want can be editable.

    Do a query that returns the Cut property records. Do another query that returns the Fat property records. Do another query that joins the first 2.

    Review http://allenbrowne.com/func-concat.html
    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
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Thank you so much for looking at this for me. I have now got the views and combined them so it gives me one row. As you point out I cant update the data in the fields. Any thoughts on how I should go about making the data available to update. It needs to be in a data sheet format as it is going to be used for stock update and so there is a lot of products to update in one go. Any ideas or points would be gratefully received. Thanks Tony

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Maybe two subforms side-by-side?
    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.

  5. #5
    tonygg is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    115
    Thank you. Not sure how to do this. Would this look like a table where you could tab between the fields in a row? If so could you help me with how to setup such a side by side form (sorry to have to ask).

    Many thanks

    Tony

  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,929
    It's just two subforms sitting on another form. Would have to click in/out of each.
    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. Replies: 9
    Last Post: 02-04-2015, 03:35 PM
  2. Replies: 5
    Last Post: 05-10-2014, 10:05 AM
  3. Replies: 5
    Last Post: 04-10-2012, 08:53 AM
  4. Combining value in multiple rows into new field
    By stricklanpbs in forum Access
    Replies: 4
    Last Post: 05-05-2011, 11:29 AM
  5. Access to Excel transferring multiple rows to single row
    By peter_lawton in forum Import/Export Data
    Replies: 10
    Last Post: 09-23-2009, 10:16 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