It would be possible to do this with an ActiveX script and two recordsets. However, you should look in Books OnLine (in SQL Server online documentation) for Data Shaping...you can write one query that will organize your data hierarchically...
hth,
Michael
Michael Weiss