Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I change a list of customers with multiple lines, and details into a single account line with categories

Example Table, Turn this

CustID CustName SalesRepName SalesRepSpecialty
1 ACME Corp Steve P Servers
1 ACME Corp Susy Q Network
1 ACME Corp John D Storage
2 MicroStuff Auntie Irma Network
3 O-Rickle Daddy Larry Servers

and turn this into

CustId CustName Server Network Storage
1 ACME Corp Steve P Suzy Q John D
2 MicroStuff Auntie Irma
3 O-Rickle Daddy Larry

Is this possible to do in MS Access?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the Crosstab Query Wizard in Access to create a TRANSFORM statement (Microsoft Access SQL):

TRANSFORM Max(Turn.SalesRepName) AS MaxOfSalesRepName
SELECT Turn.CustID, Turn.CustName
FROM Turn
GROUP BY Turn.CustID, Turn.CustName
PIVOT Turn.SalesRepSpecialty;

To get the ordering of the columns right, you can append this clause manually (before the ;):

IN (Servers, Network, Storage)

This also has the advantage that these columns will be created even when the corresponding SalesRepSpecialty is missing; however, new values will not automatically be appended. If you create an Access Report based on this query, then you need a fixed set of columns to be able to add a field for them (unless you do some complex dynamic stuff in VBA).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading