Marshall,
What's the problem with using:
INSERT INTO TempTable FROM ComplicatedQuery
This assumes that TempTable exists and has the same structure as
ComplicatedQuery.
instead of
SELECT * INTO TempTable FROM ComplicatedQuery
This doesn't assume anything and therefore I like it more, but that is just
a matter of style.
If you rally have a problem using an append query, can you
let the table hang around after the report closes and delete
in in the open event just before running the make table
query? Unless there is a lot of data, it shouldn't matter.
The maketable query has the same effect, when it is wrapped in like this:
Private Sub Report_Open(Cancel As Integer)
Dim SQL As String
' Reduce complexity of report by storing query results into temporary
tables
SQL = "SELECT * INTO TempTable FROM ComplicatedQuery;"
DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.SetWarnings True
....
Either way, be prepared to make a backup and Compact
frequently. Instead of bloating you database file,
you should seriously consider
http://www.granite.ab.ca/access/temptables.htm
This includes an interesting hint:
It seemed to be the kind of solution I was looking for, so I tried:
Private Sub Report_Close()
' Cleanup temporary tables created by report
Dim SQL As String
SQL = Me.RecordSource
Me.RecordSource = ""
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "TempTable"
DoCmd.SetWarnings True
Me.RecordSource = SQL
End Sub
But this apparently does not work for reports, since it results in a
run-time error 2191:
You can't set the Record Source property in print preview or after printing
has started