Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To accomplish your task you will need to use code. One solution, using more meaningful names, is as follows:</p> <p>Main table with two applicable columns:</p> <blockquote> <p>Table Name: Widgets</p> <p>Field 1: ID (Long)</p> <p>Field 2: Color (Text 32)</p> </blockquote> <p>Add table with two columns:</p> <blockquote> <p>Table Name: ColorListByWidget</p> <p>Field 1: ID (Long)</p> <p>Field 2: ColorList (Text 255)</p> </blockquote> <p>Add the following code to a module and call as needed to update the ColorListByWidget table:</p> <pre><code>Public Sub GenerateColorList() Dim cn As New ADODB.Connection Dim Widgets As New ADODB.Recordset Dim ColorListByWidget As New ADODB.Recordset Dim ColorList As String Set cn = CurrentProject.Connection cn.Execute "DELETE * FROM ColorListByWidget" cn.Execute "INSERT INTO ColorListByWidget (ID) SELECT ID FROM Widgets GROUP BY ID" With ColorListByWidget .Open "ColorListByWidget", cn, adOpenForwardOnly, adLockOptimistic, adCmdTable If Not (.BOF And .EOF) Then .MoveFirst Do Until .EOF Widgets.Open "SELECT Color FROM Widgets WHERE ID = " &amp; .Fields("ID"), cn If Not (.BOF And .EOF) Then Widgets.MoveFirst ColorList = "" Do Until Widgets.EOF ColorList = ColorList &amp; Widgets.Fields("Color").Value &amp; ", " Widgets.MoveNext Loop End If .Fields("ColorList") = Left$(ColorList, Len(ColorList) - 2) .MoveNext Widgets.Close Loop End If End With End Sub </code></pre> <p>The ColorListByWidget Table now contains your desired information. Be careful that the list (colors in this example) does not exceed 255 characters.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload