I have a string variable (strReport) for storing a report name and a string variable (strSQL) which I use to build up a sql statement. I want to pass strSQL as the source for the report strReport and open the report for preview.
I have this code that does it when in the development environment:
DoCmd.OpenReport strReport, acViewDesign
Reports(0).RecordSource = strSQL
DoCmd.OpenReport strReport, acViewPreview
but obviously the first line crashes when running the mde.
What code can i use to achieve this?