Search code examples
printingnavigationreportms-access-2010subform

printing a report in a navigation subform


I have built a database using MS Access 2010, everything is done except for one button that is not working.

I have a main navigation form, that has different tabs, one tab opens another navigation form (secondary nav. form - SNF) inside the main navigation form (MNF). in the SNF there are tabs which open reports that get their data from queries.

the reports, when opened separately, have a print button which works fine when the report are opened directly and not using the forms. when the reports are opened through the SNF and the print button pressed the printed page has the SNF and the MNF headers and footers which isn't needed and the supposedly 1 page report would be divided to 4 pages. each containing a quarter of the view.

what I am trying to do is have the printing function using the button print only the report inside the SNF without anything outside that reports borders just as it does when the report is opened directly without using the forms.

NOTE: * The printing button uses the defaut access print function which is implemented using the button wizard. ** Attached is a screenshot of what I get in both cases.


Solution

  • I was having the same issues, where the entire form was being printed instead of the reports that were navigation subforms. I worked around it this way:

    VBA:

    DoCmd.OpenReport "MY REPORT", acViewPreview
    DoCmd.RunCommand acCmdPrint
    DoCmd.Close acReport, "MY REPORT"
    

    It's clumsy, but it allows the user to use the print dialogue instead of just using

    DoCmd.OpenReport, "MY REPORT", acPrint
    

    and not being given the option choosing a printer, double sided etc.