CreateReport using template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ginge6000
    New Member
    • Feb 2008
    • 10

    CreateReport using template

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

    Code:
    Set rpt = CreateReport( , strTemplate)
    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

    Code:
    DoCmd.CopyObject , strQReport, acReport, strTemplate    DoCmd.OpenReport strQReport, acViewDesign, , , acHidden
    Set rpt = Reports.Item(strQReport)
    rpt.RecordSource = strQTableName
    DoCmd.Close acReport, strQReport, acSaveYes
    Both times I open the report using

    Code:
    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?
  • ginge6000
    New Member
    • Feb 2008
    • 10

    #2
    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!

    Comment

    • Scott Price
      Recognized Expert Top Contributor
      • Jul 2007
      • 1384

      #3
      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

      Comment

      • ginge6000
        New Member
        • Feb 2008
        • 10

        #4
        That's my problem....ther e 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!

        Comment

        • Scott Price
          Recognized Expert Top Contributor
          • Jul 2007
          • 1384

          #5
          How does it create the table? Can you post the subroutine used for that, including the variable declarations?

          Regards,
          Scott

          Comment

          Working...