H
Howard
I am currently rewriting a big database from using things like
DoCmd.OpenReport "Rpt_Y10_A2C_movement_by_student", acViewPreview,
where the report's data source is a saved query, to something like
Set db = CurrentDb
strSQL = SQL_Y10_A2C_movement_by_student 'generate sql from a function
db.Execute strSQL, dbFailOnError 'run sql
Set db = Nothing
where the SQL (copied from the original query) is held in a function
eg
Private Function SQL_Qry_Y10_A2C_movement_by_student() As String
Dim s As String
s = ""
s = s & "SELECT Y10_ALL_Est_num_A2C_1.Adno, "
s = s & Blah Blah Blah
SQL_Qry_Y10_A2C_movement_by_student = s
End Function
This is to speed it up and prevent warnings when using action queries.
Qn
Can I somehow make a report's data source be the result of the
db.execute's SQL? Or do I need to change all my select SQLs to 'make
table' ones and base my reports on the resulting table. This seems a bit
unnecessary ans maybe will be just as slow.
DoCmd.OpenReport "Rpt_Y10_A2C_movement_by_student", acViewPreview,
where the report's data source is a saved query, to something like
Set db = CurrentDb
strSQL = SQL_Y10_A2C_movement_by_student 'generate sql from a function
db.Execute strSQL, dbFailOnError 'run sql
Set db = Nothing
where the SQL (copied from the original query) is held in a function
eg
Private Function SQL_Qry_Y10_A2C_movement_by_student() As String
Dim s As String
s = ""
s = s & "SELECT Y10_ALL_Est_num_A2C_1.Adno, "
s = s & Blah Blah Blah
SQL_Qry_Y10_A2C_movement_by_student = s
End Function
This is to speed it up and prevent warnings when using action queries.
Qn
Can I somehow make a report's data source be the result of the
db.execute's SQL? Or do I need to change all my select SQLs to 'make
table' ones and base my reports on the resulting table. This seems a bit
unnecessary ans maybe will be just as slow.