I have several dynamically created cross tab queries that I need to place into a table. These cross tab queries are created in VBA and look like the following:
strSQL1 = "TRANSFORM Count(RecordNumber) AS [The Value] SELECT 1 AS Header" _
& "FROM qryMIRs GROUP BY 1 PIVOT Format([DateInvestigationInitiated],""mmm-yy""
In" _
& "(""" & Format(DateAdd("m", -1, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -2, Now()), "mmm-yy"
_
& """,""" & Format(DateAdd("m", -3, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -4, Now()), "mmm-yy"
_
& """,""" & Format(DateAdd("m", -5, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -6, Now()), "mmm-yy"
_
& """,""" & Format(DateAdd("m", -7, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -8, Now()), "mmm-yy"
_
& """,""" & Format(DateAdd("m", -9, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -10, Now()), "mmm-yy"
_
& """,""" & Format(DateAdd("m", -11, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -12, Now()), "mmm-yy"
& """
;"
I am currently making them the "Record Source" for reports that are then used as sub reports on a main report to make lists of data in a drawn table. Now I've been asked to perform calculations on the data to come up with totals and percentages. I can easily do this if I had all of the data stored in a table, but I can't seem to figure out how to take these cross tab queries made in VBA and turn them into tables. I tried to used the queries as the from portion of a "SELECT * INTO [tablename] FROM (query)" SQL statement but I keep getting a syntax error on the FROM statement. Does anyone have any ideas of how I could get this data into a table?
Thanks for your help in advance,
BAKEMAN![[pimp] [pimp] [pimp]](/data/assets/smilies/pimp.gif)
strSQL1 = "TRANSFORM Count(RecordNumber) AS [The Value] SELECT 1 AS Header" _
& "FROM qryMIRs GROUP BY 1 PIVOT Format([DateInvestigationInitiated],""mmm-yy""
& "(""" & Format(DateAdd("m", -1, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -3, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -5, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -7, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -9, Now()), "mmm-yy"
& """,""" & Format(DateAdd("m", -11, Now()), "mmm-yy"
I am currently making them the "Record Source" for reports that are then used as sub reports on a main report to make lists of data in a drawn table. Now I've been asked to perform calculations on the data to come up with totals and percentages. I can easily do this if I had all of the data stored in a table, but I can't seem to figure out how to take these cross tab queries made in VBA and turn them into tables. I tried to used the queries as the from portion of a "SELECT * INTO [tablename] FROM (query)" SQL statement but I keep getting a syntax error on the FROM statement. Does anyone have any ideas of how I could get this data into a table?
Thanks for your help in advance,
BAKEMAN
![[pimp] [pimp] [pimp]](/data/assets/smilies/pimp.gif)