Access has, IMNSHO, the very best relational reporting engine of any
"desktop" database, for reporting what _is there_. What you are asking is
that it report something that _isn't there_ in the form you want, so that
will require that we add functionality to create what you want from what you
actually have.
In Access terms, I wonder what would you call a "sub-list"? If it is a
related table, perhaps the following would work.
For a main Table named tblLists, containing a Number (Long Integer) Field
named Qty (as yours is) and a Text Field named List. A related Table is
named tblListItems with a TextField named List (which corresponds to the
List Field of tblLists) and a Text Field named ListItem (the items which are
concatenated to build your "sub-List").
A function, ConcatL:
Public Function ConcatL(pstrLName As String) As String
' Reads appropriate List from tblListItems, concatenates the List Item in a
' String and returns that String
Dim db As DAO.Database
Dim tb As DAO.Recordset
Dim strSQL As String
Dim strConcatList As String
Set db = CurrentDb()
strSQL = "SELECT * FROM tblListItems WHERE
- = """ & pstrLName &
""""
Set tb = db.OpenRecordset(strSQL)
If Not (tb.BOF And tb.EOF) Then
tb.MoveFirst
Do While Not tb.EOF
If Len(strConcatList & "") < 1 Then
strConcatList = tb("ListItem")
Else
strConcatList = strConcatList & ", " & tb("ListItem")
End If
tb.MoveNext
Loop
End If
tb.Close
Set tb = Nothing
Set db = Nothing
ConcatL = strConcatList
Exit_Proc:
Exit Function
A Query built in the Query Builder with only tblLists as a data source,
Fields Qty and Lists brought down into the grid, and a calculated Column
sub-List: ConcatL(
- ), whose SQL is:
SELECT tblLists.Qty, tblLists.List, ConcatL(
- ) AS [sub-List]
FROM tblLists;
Returns what you desire as Output. If you do not find it is trivial to
replace the table and column names with your own and create the report -- I
expect it will be trivial -- please post back with the specific problems you
are having.
Larry Linson
Microsoft Access MVP
As I mentioned earlier, it's a sub-list.
An example would be:
Quantity List sub-List
123 A
A1
A2
A3
456 B
B1
B2
B3
The code will concatenate A1 to B3. I want to keep A and B seperate but
only tab-delimited A1, A2, A3 etc.
Your opinion, I cannot remove the quantity or the main list into the
page header. That will have to remain in the list header.
Thanks,
Zef