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

CreateReport using template

P: 10
Hi, I'm trying to create a report using a template and then set it's recordsource. I have tried

Expand|Select|Wrap|Line Numbers
  1. Set rpt = CreateReport( , strTemplate)
  2. rpt.RecordSource = strQTableName
but even though the template report exists and I have spelt it correctly I always end up with a blank report.

So now I have tried

Expand|Select|Wrap|Line Numbers
  1. DoCmd.CopyObject , strQReport, acReport, strTemplate    DoCmd.OpenReport strQReport, acViewDesign, , , acHidden
  2. Set rpt = Reports.Item(strQReport)
  3. rpt.RecordSource = strQTableName
  4. DoCmd.Close acReport, strQReport, acSaveYes
  5.  
Both times I open the report using

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport strQReport, acViewPreview, , , acWindowNormal
but although it does create a report using the template on opening it asks for a Parameter called Number which doesn't match up to any parameter on the report...... Also (it is creating an exam paper) it puts the questions in a wierd order (always 16,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,30,17,18,29 ,20,21,22,23,24,25,26,27,28,19)

I'd prefer to use the CreateReport method as it seems cleaner to me but can anyone help?
Feb 15 '08 #1
Share this Question
Share on Google+
4 Replies


P: 10
Sorted the strange numbering issue - just created set the OrderBy value at the same time as the record source. Now i just need to find this misterious parameter! I would still like some understanding as to why createreport doesn't work!
Feb 15 '08 #2

Scott Price
Expert 100+
P: 1,384
The parameter must be hidden in a query somewhere down the line. Without knowing what queries and dependencies you have, it's a little hard to say!

The first thing I'd do is to take a very careful look at each query that you are using. That's the most likely cause.

Regards,
Scott
Feb 15 '08 #3

P: 10
That's my problem....there are no stored queries used in the production of the reports. Only VBA that creates a table and then a report based on the table. I've done a (Ctrl+F) search in the code for "Number" and it doesn't appear (except in comments!) I'm very confused!
Feb 15 '08 #4

Scott Price
Expert 100+
P: 1,384
How does it create the table? Can you post the subroutine used for that, including the variable declarations?

Regards,
Scott
Feb 15 '08 #5

Post your reply

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