• Access Report (Access 2002)

    Author
    Topic
    #402663

    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:

    Error #: 2451 The report name ‘tblClaimsCosts subreport’ you entered is misspelled or refers to a report that isn’t open or doesn’t exist.

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #803148

      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.)

      • #803485

        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.

        • #803714

          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”

          • #804015

            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.

          • #804016

            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.

        • #803715

          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”

      • #803486

        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.

      • #803633

        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.

        • #803645

          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.

        • #803646

          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.

      • #803634

        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.

    • #803149

      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.)

    Viewing 1 reply thread
    Reply To: Access Report (Access 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: