Solved

MS Access and rotate data

Posted on 2016-11-02
4
44 Views
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?
0
Comment
Question by:HLRosenberger
4 Comments
 
LVL 27

Assisted Solution

by:MacroShadow
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")

	rs.MoveFirst
	Do Until rs.EOF
		rs.Edit
		str = str & " " & rs!ColorFieldName
		rs.MoveNext
	Loop
	rs!ColorFieldName = str
	rs.Update
	rs.Close
	Set rs = Nothing
End Sub

Open in new window

0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 41870295
0
 
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:

https://www.experts-exchange.com/articles/2380/Domain-Aggregate-for-Concatenating-Values-by-Group-in-Microsoft-Access.html

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

Jim.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41870362
Thanks for all the help!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

776 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