> If I knew the number of columns (and their names)
those are in the result set from your first query --
SELECT DISTINCT RecordID
FROM tblCrosstab
ORDER BY RecordID
loop through those creating a TH for each name (RecordID)
why do you want to know the number?
rudy