Results 1 to 7 of 7
  1. #1
    HansBades is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2021
    Posts
    85

    Grouping Data

    I have a query that produces the line items of a Work Order as shown in the first table below. How can I modify the query to organize the same data in one record as shown with the format of the second table below? Thanks.



    Work Order Number Department Item Approval Code
    1 Facilities Repair Window 1
    1 Facilities Replace Carpet 2
    1 Facilities Paint Door 1
    2 IT Replace Cabinets 3


    Work Order Number Department Item Approval Code
    1 Facilities Repair Window, Replace Carpet, Paint Door 1, 2
    2 IT Replace Cabinets 3

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    You cannot. Queries don’t work that way.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Use Allen Browne's Concatenate perhaps? http://allenbrowne.com/func-concat.html

    Or theDBGuy's function http://www.accessmvp.com/thedbguy/co...itle=simplecsv
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    HansBades is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2021
    Posts
    85
    The Concatenate functions worked amazingly well. I was surprised how easy it was but I have a problem. My WorkOrder Table is linked to my WorkOrderSKus table in a one to many relationship with WorkOrderID in WorkOrder linking to WorkOrderIDFK in the WorkOrderSkus table. The WorkOrderSkus table has a field ApprovalCodeTypeFK that specifies the approval code for each part requisitioned for a particular Work Order. The ApprovalCodeType table links (ApprovalCodeTypeID being the PK) in a one to many relationship to the WOrkORderSkus table to the ApprovalCodeTypeFK field. So when I run the function it lists my WorkOrder Name, it groups the approval code numbers instead of the actual names of the approval codes. I would like it to group the descriptions of the approval code. Any ideas?


    Table:WorkOrders
    WorkOrderID WorkOrderName WorkOrderDate
    1 Replace Cafeteria Windows Jan 2, 2022
    2 Replace Warehouse Door Jan 4, 2022

    Table:WorkOrderSkus
    WorkOrderSKUID WorkOrderIDFK SKUs ApprovalCodeIDFK
    1 1 Window5jl 1
    2 1 WindowScreen5jl 4
    3 2 DoorFrame 2
    4 2 CustomDoorhandle 3

    Table:ApprovalCodeType
    ApprovalCodeID ApprovalCodeDescription
    1 Cheapest of available parts
    2 Only part available for the project
    3 Not cheapest but needed to maintain cosmetic appearance
    4 Special order request approved by management


    WorkOrderID ApprovalCodeTypeID
    1 1,4
    2 2,3


    I would like it output the following:
    WorkOrderID ApprovalCodeTypeID
    1 Cheapest of available parts, Special order request approved by management
    2 Only part available for the project, Not cheapest but needed to maintain cosmetic appearance

  5. #5
    HansBades is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2021
    Posts
    85
    I figured out a way to do it. Likely not the most efficient but it works.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,900
    Build a query that joins tables and use that as source for concatenation.
    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
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    An alternative is to export your query result to Power Pivot and then write two measures in DAX to present the results you wish. Here is a link to a tutorial on how to do this.

    https://sfmagazine.com/post-entry/ju...a-pivot-table/

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

Similar Threads

  1. Grouping Data by dates
    By chr1stoper1 in forum Access
    Replies: 5
    Last Post: 01-17-2017, 02:26 PM
  2. Help with grouping data for a report
    By PBMike in forum Reports
    Replies: 3
    Last Post: 05-22-2013, 11:47 PM
  3. Grouping Data
    By chan069 in forum Access
    Replies: 2
    Last Post: 02-14-2013, 12:40 AM
  4. Grouping of data
    By tkandy in forum Queries
    Replies: 7
    Last Post: 05-09-2011, 06:07 PM
  5. Grouping data in Report
    By Leelers in forum Reports
    Replies: 1
    Last Post: 02-20-2009, 08:49 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