All,
I'm creating a new report via code using the following lines:
- Dim rpt As Report
-
Set rpt = CreateReport(, "PIVOT_SUMMARY_tmp")
Problem is Access 2002 (VB) is not using the template report (denoted by "PIVOT_SUMMARY_tmp") when it creates the new report. Access just uses the default report template which is a blank slate.
I'm pretty sure that I'm using the correct syntax. I've even referred to Mary McCarthy's article Create Dynamic Report using VBA, but I can't seem to figure out why Acceess wont use my template report.
Can anyone provide a few hints as to why Access isn't using my template report?
Thanks,
Scott
All,
It took lot of digging, but I figured out the answer to my own question (mostly due to a post in another forum -
dBforums). When using
CreateRoport method in VB, the programer has the option of specifying a 'template' report. However, this option does not work as one might expect. The 'template' is only used for section size. VB will not 'copy' the controls and other properties that may have been setup for the template to the new report.
So, when creating a new report based of a 'template', you must use the following code:
- Dim rpt As Report
-
-
DoCmd.CopyObject , "New_rpt", acReport, "Template_rpt"
-
DoCmd.OpenReport "New_rpt", acViewDesign
-
Set rpt = Reports![New_rpt]
Now that I look at it, it's like "duh"! Oh well, I hope this posting helps someone else in the future.
Scott