MS Access and rotate data

Posted on 2016-11-02
Last Modified: 2016-11-02
Is there a way to rotate data in SQL or other mechanism in MS Access?  For example, say I have 3 records of data, say text string of colors  - "blue", "red", "green".   Is there a way to return a concatenation of all three colors in one string in one record?
Question by:HLRosenberger
LVL 27

Assisted Solution

MacroShadow earned 125 total points
ID: 41870294
You can use a recordset. This example will replace the last record with the concatenated value.
Sub Demo()
	Dim rs As DAO.Recordset
	Dim str As String

	Set rs = CurrentDb.OpenRecordset("table")

	Do Until rs.EOF
		str = str & " " & rs!ColorFieldName
	rs!ColorFieldName = str
	Set rs = Nothing
End Sub

Open in new window

LVL 119

Accepted Solution

Rey Obrero earned 250 total points
ID: 41870295
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 125 total points
ID: 41870299
Use the following to flatten row data:

Access does have a crosstab (PIVOT), but nothing to flatten built-in.


Author Closing Comment

ID: 41870362
Thanks for all the help!

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
view mode vs edit mode 17 47
combine ShipTo and BillTo Address 3 22
Need more help autopopluating a number field 17 30
how to link subforms ms/access VBA 6 27
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now