combine multiple records in a single (1 Viewer)

r621

New member
Local time
Today, 04:30
Joined
Dec 18, 2020
Messages
24
Dears , I need one time again your help, I've a table as following:

TAGNoINSTRUMENT TYPESh
99-PP-3001ALARM33
99-PP-3002ALARM33
99-PP-3003ALARM33
99-PP-3004ALARM33
99-PP-3005ALARM33
99-PP-3006ALARM33
99-PP-3007ALARM33
99-PP-3008ALARM33

I need to combine all the records in a single record. I've tried with INNER JOIN but is not working as I want, the common point for all records is the column Sh value 33 which is my sheet number :
Basically I've to combine all records as following (just a sample I've not reported all records)

99-PP-3002ALARM3399-PP-3003ALARM3399-PP-3004ALARM33

Could you please help me
 

Josef P.

Well-known member
Local time
Today, 04:30
Joined
Feb 2, 2023
Messages
833
Would a pivot table with column numbers 1-n be possible?

like:
Code:
TRANSFORM Max(TAGNo) AS MaxTAGNo
SELECT
     sh, [INSTRUMENT TYPE]
FROM (
      SELECT
             TagNo, [INSTRUMENT TYPE], sh,
             DCount("*","YourTable","sh = " & [sh] & " and TagNo <= '" & [TagNo] & "'") AS N
      FROM
            YourTable
   )  AS Q
GROUP BY sh, [INSTRUMENT TYPE]
PIVOT N
 
Last edited:

plog

Banishment Pending
Local time
Yesterday, 21:30
Joined
May 11, 2011
Messages
11,653
What's the big picture? What will your data in this format allow you to achieve? Perhaps there is a better way to achieve that end goal.
 

r621

New member
Local time
Today, 04:30
Joined
Dec 18, 2020
Messages
24
Hello Plog, I shall have a single record because I need to import that format in program for automatic drawing
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:30
Joined
Feb 19, 2002
Messages
43,368
Do you mean export? The data is already in the correct structure in the table you posted. Are you trying to export the normalized data into a one line format for the use of a different application? Look here for the concat function. That is a VBA procedure that you can modify that will read a table and create a string that contains data from multiple rows in the table.
 

June7

AWF VIP
Local time
Yesterday, 18:30
Joined
Mar 9, 2014
Messages
5,488
theDBGuy provided the simplest record concatenation code I've seen. If you want another example, review http://allenbrowne.com/func-concat.html

However, seems to me the output should not repeat ALARM and 33 values. Why not showing TAG_No 99-PP-3001?
 

Users who are viewing this thread

Top Bottom