I'm using the Concat function from this thread, and I'm wondering if it's possible to run the function multiple times, so it won't save what's been passed by previous records with the same IOSC?
(I'm pretty new to this, so I apologize if the answer is obvious).
An alternative answer which better displays the flexible nature of this code, is included below. Notice this doesn't affect the calling code (SQL) at all.
Paste this function into a module then run a query with the SQL below.
Example
TABLE1:
IOSC: FEATURE:
00029 LH
00029 SWFTERM
00029 WATS
00031 1PTY
00031 BUS
00031 FR
00031 LS
00031 SWFBOTH
00031 TC
00573 FAXTHRU
00963 1PTY
00963 BUS
00963 FR
00963 LS
00963 SWFBOTH
00963 TC
Function Output from TABLE1 (works like a charm from what was provided in the thread!)
IOSC: FEATURE:
00029 LH,SWFTERM,WATS
00031 PTY, BUS, FR, LS, SWFBOTH, TC
00573 FAXTHRU
00093 1PTY, BUS, FR, LS, SWFBOTH, TC
But, if I run the function immediately after for the following info below, this is what I see:
TABLE2
IOSC: AGNCY:
00029 DWQ
00029 UGS
00029 DWQ
00031 DWQ
00031 DWQ
00031 UGS
00031 UGS
00031 DWQ
00031 DWQ
00573 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
Function Output from TABLE2. (Info from the Function Output from Table1 is still retained)
IOSC: FEATURE:
00029 LH,SWFTERM,WATS , DWQ,UGS
00031 PTY, BUS, FR, LS, SWFBOTH, TC, DWQ,UGS
00573 FAXTHRU, DWQ
00093 1PTY, BUS, FR, LS, SWFBOTH, TC, DWQ
Desired display
IOSC: FEATURE:
00029 DWQ,UGS
00031 DWQ,UGS
00573 DWQ
00093 DWQ
So, is it possible to run the function multiple times without retaining what's been passed by previous records with the same IOSC?
Thank you for your help!
(I'm pretty new to this, so I apologize if the answer is obvious).
An alternative answer which better displays the flexible nature of this code, is included below. Notice this doesn't affect the calling code (SQL) at all.
Paste this function into a module then run a query with the SQL below.
Code:
'Concat Returns lists of items which are within a grouped field
Public Function Concat(strGroup As String, _
strItem As String) As String
Static strLastGroup As String
Static strItems As String
If strGroup = strLastGroup Then
strItems = strItems & ", " & strItem
Else
strLastGroup = strGroup
strItems = strItem
End If
Concat = strItems
End Function
Code:
SELECT IOSC, Max(Concat(IOSC, Feature)) AS Features FROM [YourTable] GROUP BY IOSC
TABLE1:
IOSC: FEATURE:
00029 LH
00029 SWFTERM
00029 WATS
00031 1PTY
00031 BUS
00031 FR
00031 LS
00031 SWFBOTH
00031 TC
00573 FAXTHRU
00963 1PTY
00963 BUS
00963 FR
00963 LS
00963 SWFBOTH
00963 TC
Function Output from TABLE1 (works like a charm from what was provided in the thread!)
IOSC: FEATURE:
00029 LH,SWFTERM,WATS
00031 PTY, BUS, FR, LS, SWFBOTH, TC
00573 FAXTHRU
00093 1PTY, BUS, FR, LS, SWFBOTH, TC
But, if I run the function immediately after for the following info below, this is what I see:
TABLE2
IOSC: AGNCY:
00029 DWQ
00029 UGS
00029 DWQ
00031 DWQ
00031 DWQ
00031 UGS
00031 UGS
00031 DWQ
00031 DWQ
00573 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
00963 DWQ
Function Output from TABLE2. (Info from the Function Output from Table1 is still retained)
IOSC: FEATURE:
00029 LH,SWFTERM,WATS , DWQ,UGS
00031 PTY, BUS, FR, LS, SWFBOTH, TC, DWQ,UGS
00573 FAXTHRU, DWQ
00093 1PTY, BUS, FR, LS, SWFBOTH, TC, DWQ
Desired display
IOSC: FEATURE:
00029 DWQ,UGS
00031 DWQ,UGS
00573 DWQ
00093 DWQ
So, is it possible to run the function multiple times without retaining what's been passed by previous records with the same IOSC?
Thank you for your help!
Comment