Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Feb 2010
    Location
    Denver, CO
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access Report (Access 2002)

    I have an access report that has a subreport whose Recordsource property has to be modified during runtime. This is not a problem in acViewPreview mode, but when I go to actually print the report (which will re-run most if not all the code), I get the following error:

    <font color=blue> Error #: 2451 The report name 'tblClaimsCosts subreport' you entered is misspelled or refers to a report that isn't open or doesn't exist.</font color=blue>

    I have verified that the table is not misspelled. I tried to include some code to open the subreport in order to edit the properties, but that produced another error altogether. I think I have further learned that you cannot "Open" a report while "printing" it. Does anyone know how I should go about modifying properties of a report that is in the process of being printed?

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Access Report (Access 2002)

    Where are you trying to set the RecordSource property for the subform? (It should probably be in the OnFormat event for the main report rather than that event for the subform.)
    Wendell

  3. #3
    2 Star Lounger
    Join Date
    Feb 2010
    Location
    Denver, CO
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Report (Access 2002)

    Wendell--

    Thanks for your response. I really appreciate all the help you give

    I need to make sure I'm not missing something. I cannot find an OnFormat event for the main report. There is an OnFormat event for the detail section of the main report. Is that what you meant? I tried that, but it didn't fire until after the Open event of the subreport. I think I need this code to fire prior to the opening of the subreport.

    So I move the code to the open event of the main report. This does not seem to work, either. Now I am getting the following error message: " Error: 2046, The command or action 'OpenReport' isn't available now." Is there an event that fires prior to even opening the main report? or do I need to move this code to the click event of the button that calls the report in the first place? I think I'll play with that for a while.

  4. #4
    2 Star Lounger
    Join Date
    Feb 2010
    Location
    Denver, CO
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Report (Access 2002)

    OK, moving the code to Report_Open for the main report didn't really change anything. I think I've learned that the Open event fires too late for my uses.

    Does anyone have any ideas on where I would put code to change the property of a report during runtime. I've tried Open and OnFormat.

  5. #5
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Access Report (Access 2002)

    Sorry - I've been out of touch for several hours. It seems something is amiss here - the Open event is the first thing that happens to a report, so at that point the subreport isn't open. However by the time the detail section is being formatted, it should have the subreports open, and you should be able to set the data source for them. That presumes of course that the subreports are in the detail section, not in a header or a footer. If they are in a header or a footer, you should be able to use the OnFormat event to set the data property. I would suggest however, that using dynamic datasources for reports can be a problematic situation, especially if parameter queries are used - that will often cause multiple prompts for a preview, and then the same prompts when you print, often twice depending on the design. You might be better off to create a temporary table, and use that temporary table as your data source.
    Wendell

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Access Report (Access 2002)

    Why would you be using OpenReport in dealing with a subreport? A subreport is a child object of the parent report and you have to refer to it as such:

    Me!subreportcontrolname.Report.Recordsource = "qryWhatever"
    Charlotte

  7. #7
    2 Star Lounger
    Join Date
    Feb 2010
    Location
    Denver, CO
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access Report (Access 2002)

    Thanks, Charlotte, for your input. Sometimes I feel like I'm still learning some of the finer points of Access. It never occurred to me to refer to it in this way. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •