Hi all,
I have the following table in which orders are stored by each product type in a row.
However, I want to bring all product types in one cell 'field' in a query by each product type as shown in the following snapshot.
To achieve this, I copied over the following ADO function in a standard module with the help of the internet. But I keep getting an error message related to the user-defined type not found.
And then, I create the following SQL language in a query.
When I run the query, I get the following error message. Could you advise a solution?
I have the following table in which orders are stored by each product type in a row.
However, I want to bring all product types in one cell 'field' in a query by each product type as shown in the following snapshot.
To achieve this, I copied over the following ADO function in a standard module with the help of the internet. But I keep getting an error message related to the user-defined type not found.
Code:
Function ConcatADO(strSQL As String, strColDelim, _
strRowDelim, ParamArray NameList() As Variant)
Dim rs As New ADODB.Recordset
Dim strList As String
On Error GoTo Proc_Err
If strSQL <> "" Then
rs.Open strSQL, CurrentProject.Connection
strList = rs.GetString(, , strColDelim, strRowDelim)
strList = Mid(strList, 1, Len(strList) - Len(strRowDelim))
Else
strList = Join(NameList, strColDelim)
End If
ConcatADO = strList
Exit Function
Proc_Err:
ConcatADO = "***" & UCase(Err.Description)
End Function
And then, I create the following SQL language in a query.
Code:
SELECT tblOrders.[Order Number], ConcatADO("SELECT [Product Types] FROM tblOrders
WHERE [Order Number]=" & [Order Number],",","; ") AS [All Products Combined]
FROM tblOrders
GROUP BY tblOrders.[Order Number];
When I run the query, I get the following error message. Could you advise a solution?