The Access database has a SQL backend with tables, views, SP's.
I have reports to run based on rptArea and I am currently using vba but wondering if it's better to use a report table. For instance, sample vba code:
if rptArea is "Mktg" then
Case M1
rptName = "Mktg1_rpt"
strdisplayName = "MKtg1"
Docmd.OpenReport "Mktg1_rpt", acViewPreview
Reports(strReportName).Caption = strdisplayName
Case M2
.... same thing but different report
Case M3
.... same thing but different report
End Select
if rptArea is "Finance" then
Case F1
rptName = "Finance1_rpt"
strdisplayName = "Finance1"
Docmd.OpenReport "Finance1_rpt", acViewPreview
Reports(strReportName).Caption = strdisplayName
Case F2
.... same thing but different report
Case F3
.... same thing but different report
End Select
There are 12-15 rptArea .
I can do this in VBA, but was wondering if a table would be better. Then if they add a new report or delete a report, it can be done in the table.
But I don't know how to populate and run the reports from a table with the criteria from above.
Maybe TABLE:
the table would have fields:
rptArea, rptName , strdisplayName , Reports(strReportName).Caption, Docmd.OpenReport "Finance1_rpt", acViewPreview
Then the VBA would only be:
if rptArea is "Mktg" then
DLookup the table that has the criteria from above, but it would need to lookup each report, and there can be 1 or many reports per rptArea. How to loop through the table and run each report? Not sure. Looking for a way to streamline the VBA used to run the reports.
I also thought about putting the report names and other criteria in a view or SP and have it loop through there. But need help.
Any ideas, suggestions is appreciated?
Thanks,
Ben
I have reports to run based on rptArea and I am currently using vba but wondering if it's better to use a report table. For instance, sample vba code:
if rptArea is "Mktg" then
Case M1
rptName = "Mktg1_rpt"
strdisplayName = "MKtg1"
Docmd.OpenReport "Mktg1_rpt", acViewPreview
Reports(strReportName).Caption = strdisplayName
Case M2
.... same thing but different report
Case M3
.... same thing but different report
End Select
if rptArea is "Finance" then
Case F1
rptName = "Finance1_rpt"
strdisplayName = "Finance1"
Docmd.OpenReport "Finance1_rpt", acViewPreview
Reports(strReportName).Caption = strdisplayName
Case F2
.... same thing but different report
Case F3
.... same thing but different report
End Select
There are 12-15 rptArea .
I can do this in VBA, but was wondering if a table would be better. Then if they add a new report or delete a report, it can be done in the table.
But I don't know how to populate and run the reports from a table with the criteria from above.
Maybe TABLE:
the table would have fields:
rptArea, rptName , strdisplayName , Reports(strReportName).Caption, Docmd.OpenReport "Finance1_rpt", acViewPreview
Then the VBA would only be:
if rptArea is "Mktg" then
DLookup the table that has the criteria from above, but it would need to lookup each report, and there can be 1 or many reports per rptArea. How to loop through the table and run each report? Not sure. Looking for a way to streamline the VBA used to run the reports.
I also thought about putting the report names and other criteria in a view or SP and have it loop through there. But need help.
Any ideas, suggestions is appreciated?
Thanks,
Ben