Link to home
Start Free TrialLog in
Avatar of AisinAuto
AisinAuto

asked on

MS Access 2003 Query

I am trying to create a query based on the fields on the table in the file provided.  I know how to combine the fields Part Name and Part Family into one.  What I need from is in the other fields how to create a query that after i group the records in the first two fields and then count the other records in the other fields based on the first two letters in each field.  As an example the first field that would need to count is which gate broke.  The first column in the query would take Part Name and Part Family and combine them into one column and the rest of the fields in the query would be Assy, DC, FI and MC.  These would contain the count of each from the other fields in the query.
db1.mdb
Book1.xlsx
Avatar of answer_dude
answer_dude
Flag of United States of America image

Can you provide a sample of the output that you're looking to create?  I don't understand the relationship between your database table and the spreadsheet...
If I read your question correct this query might work -- however it involves some text manipulation on the "Which Gate Broke" field -- I would recommend creating another distinct field to capture the type (DC, FI, etc.)
TRANSFORM Count([Active Sorts].[Issue Number]) AS [CountOfIssue Number]
SELECT [Part Name] & " - " & [Part Family] AS Product
FROM [Active Sorts]
GROUP BY [Part Name] & " - " & [Part Family]
PIVOT IIf(Left([Which Gate Broke],2)="DC","DC",IIf(Left([Which Gate Broke],2)="FI","FI",IIf(Left([Which Gate Broke],3)="M/C","M/C",IIf(Left([Which Gate Broke],4)="Assy","Assy","Other"))));

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of answer_dude
answer_dude
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AisinAuto
AisinAuto

ASKER

Does your query include the other fields as well, Gate 2, Gate 3 and Last Gate Broke?
Sorry!!  I missed your follow up question.

My query only dealt with the "Which gate broke" field.

How would you want the other three included?  Are they additional breaks?  For example, Issue number 1-0021 has Which Gate Broke = "DC Catch Station" and Gate 2 = "DC hourly Check" and Last Gate To Break = "QC Patrol (D/C)"

So... does that translate to two DC errors and one QC error on part "9404 Upper Valve Body"

If so, then we would have to repeat what I did for the "Which gate broke" field for each of the other fields and then union/group them by part number.