By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

CreateReport Command not Using Template Report

P: 69
All,

I'm creating a new report via code using the following lines:

Expand|Select|Wrap|Line Numbers
  1. Dim rpt As Report
  2. 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
Dec 5 '07 #1
Share this Question
Share on Google+
1 Reply


P: 69
All,

I'm creating a new report via code using the following lines:

Expand|Select|Wrap|Line Numbers
  1. Dim rpt As Report
  2. 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:

Expand|Select|Wrap|Line Numbers
  1. Dim rpt As Report
  2.  
  3. DoCmd.CopyObject , "New_rpt", acReport, "Template_rpt"
  4. DoCmd.OpenReport "New_rpt", acViewDesign
  5. 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
Dec 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.