Solved

Concatenation

Posted on 2013-01-17
4
214 Views
Last Modified: 2013-01-21
I had been using Crosstab queries, but my customer wants me to combine all the related values of a particular record into one field. This has to do with surgeries where you can have multiple components and other items per surgery. What they want is to have all the components from a surgery concatenated into one field instead of using a cross tab where it has one column for each possible component.

Is this possible?
0
Comment
Question by:rawilken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:H
ID: 38789460
I'm not sure I follow. Could you show a before and after example possibly?
0
 
LVL 26

Accepted Solution

by:
jerryb30 earned 100 total points
ID: 38789725
If the surgery has a unique identifier:

Create a module with this function:

Function CatComponent(vSurgeryID as string) as string
dim strTemp as string
dim rs as dao.recordset
dim strSQL as string
strSQL = "SurgeryComponent from SurgeryTable where surgeryID = '" & vSurgeryComponent & "'"
set rs = currentdb.openrecordset (strSQL)
rs.movefirst
do while not(rs.eof)
if strTemp = "" then
strTemp = rs!SurgeryComponent
else
strTemp & vbCRLF & rs!SurgeryComponent
endif
rs.movenext
loop
CatComponent = strTemp
end function

Then, call by query

Select SurgeryID, CatComponent(SurgeryComponent) from SurgeryTable
Group by SurgeryID, CatComponent(SurgeryComponent)
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 38789733
If this is unclear, please post a sample db with dummy data (no personal identification data), with records of one surgery and multiple components.
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 38792059
Create a query and create 1 column that concatenates the fields you wish to combine, plus all the data requred for your crosstab.

Use this query as your crosstab source.

Combined_Field: Field1 & " " & Field2 & " " .........

Scott C
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

740 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