Code To Prevent Printing A Subreport

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom

    #1

    Code To Prevent Printing A Subreport

    I have a subreport that can contain one or two pictures per page. The
    subreport is similar to an appendix to the main report. The recordsource
    contains a field "IncludeInRepor t" (Yes/No) for each picture record. What
    code do I use and where does it go to prevent printing the subreport if
    there are no picture records marked "Yes" in the "IncludeInRepor t" field?

    Thanks,

    Tom


  • Allen Browne

    #2
    Re: Code To Prevent Printing A Subreport

    Create a query to use as the RecordSource of your subreport.

    In the Criteria row of the query, under the IncludeInReport field, enter:
    True

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Tom" <notmy@email.co m> wrote in message
    news:%1tKe.3521 $RZ2.3502@newsr ead3.news.atl.e arthlink.net...[color=blue]
    >I have a subreport that can contain one or two pictures per page. The
    >subreport is similar to an appendix to the main report. The recordsource
    >contains a field "IncludeInRepor t" (Yes/No) for each picture record. What
    >code do I use and where does it go to prevent printing the subreport if
    >there are no picture records marked "Yes" in the "IncludeInRepor t" field?[/color]


    Comment

    • Tom

      #3
      Re: Code To Prevent Printing A Subreport

      Allen,

      Thanks for your response!

      Please reread my post. I want to know how and where to code to prevent
      printing the subreport when there are no records marked Yes in the
      IncludeInReport field.

      Thanks,

      Tom


      "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
      news:42fab747$0 $32257$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...[color=blue]
      > Create a query to use as the RecordSource of your subreport.
      >
      > In the Criteria row of the query, under the IncludeInReport field, enter:
      > True
      >
      > --
      > Allen Browne - Microsoft MVP. Perth, Western Australia.
      > Tips for Access users - http://allenbrowne.com/tips.html
      > Reply to group, rather than allenbrowne at mvps dot org.
      >
      > "Tom" <notmy@email.co m> wrote in message
      > news:%1tKe.3521 $RZ2.3502@newsr ead3.news.atl.e arthlink.net...[color=green]
      >>I have a subreport that can contain one or two pictures per page. The
      >>subreport is similar to an appendix to the main report. The recordsource
      >>contains a field "IncludeInRepor t" (Yes/No) for each picture record. What
      >>code do I use and where does it go to prevent printing the subreport if
      >>there are no picture records marked "Yes" in the "IncludeInRepor t" field?[/color]
      >
      >[/color]


      Comment

      • Allen Browne

        #4
        Re: Code To Prevent Printing A Subreport

        Tom, I would never consider doing that in code, when you could elimiate the
        records in the *query* that the subreport is based on, so that no code is
        needed.

        Is there a special reason you wish to use code?

        --
        Allen Browne - Microsoft MVP. Perth, Western Australia.
        Tips for Access users - http://allenbrowne.com/tips.html
        Reply to group, rather than allenbrowne at mvps dot org.

        "Tom" <notmy@email.co m> wrote in message
        news:BsAKe.3829 $RZ2.2097@newsr ead3.news.atl.e arthlink.net...[color=blue]
        > Allen,
        >
        > Thanks for your response!
        >
        > Please reread my post. I want to know how and where to code to prevent
        > printing the subreport when there are no records marked Yes in the
        > IncludeInReport field.
        >
        > Thanks,
        >
        > Tom
        >
        >
        > "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
        > news:42fab747$0 $32257$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...[color=green]
        >> Create a query to use as the RecordSource of your subreport.
        >>
        >> In the Criteria row of the query, under the IncludeInReport field, enter:
        >> True
        >>
        >> "Tom" <notmy@email.co m> wrote in message
        >> news:%1tKe.3521 $RZ2.3502@newsr ead3.news.atl.e arthlink.net...[color=darkred]
        >>>I have a subreport that can contain one or two pictures per page. The
        >>>subreport is similar to an appendix to the main report. The recordsource
        >>>contains a field "IncludeInRepor t" (Yes/No) for each picture record. What
        >>>code do I use and where does it go to prevent printing the subreport if
        >>>there are no picture records marked "Yes" in the "IncludeInRepor t" field?[/color][/color][/color]


        Comment

        • Tom

          #5
          Re: Code To Prevent Printing A Subreport

          The subreport has titles and a logo. It prints when there are no records
          marked Yes in the IncludeInReport field.

          Tom


          "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
          news:42fae474$0 $32252$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...[color=blue]
          > Tom, I would never consider doing that in code, when you could elimiate
          > the records in the *query* that the subreport is based on, so that no code
          > is needed.
          >
          > Is there a special reason you wish to use code?
          >
          > --
          > Allen Browne - Microsoft MVP. Perth, Western Australia.
          > Tips for Access users - http://allenbrowne.com/tips.html
          > Reply to group, rather than allenbrowne at mvps dot org.
          >
          > "Tom" <notmy@email.co m> wrote in message
          > news:BsAKe.3829 $RZ2.2097@newsr ead3.news.atl.e arthlink.net...[color=green]
          >> Allen,
          >>
          >> Thanks for your response!
          >>
          >> Please reread my post. I want to know how and where to code to prevent
          >> printing the subreport when there are no records marked Yes in the
          >> IncludeInReport field.
          >>
          >> Thanks,
          >>
          >> Tom
          >>
          >>
          >> "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
          >> news:42fab747$0 $32257$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...[color=darkred]
          >>> Create a query to use as the RecordSource of your subreport.
          >>>
          >>> In the Criteria row of the query, under the IncludeInReport field,
          >>> enter:
          >>> True
          >>>
          >>> "Tom" <notmy@email.co m> wrote in message
          >>> news:%1tKe.3521 $RZ2.3502@newsr ead3.news.atl.e arthlink.net...
          >>>>I have a subreport that can contain one or two pictures per page. The
          >>>>subreport is similar to an appendix to the main report. The recordsource
          >>>>contains a field "IncludeInRepor t" (Yes/No) for each picture record.
          >>>>What code do I use and where does it go to prevent printing the
          >>>>subreport if there are no picture records marked "Yes" in the
          >>>>"IncludeInR eport" field?[/color][/color]
          >
          >[/color]


          Comment

          • Allen Browne

            #6
            Re: Code To Prevent Printing A Subreport

            That doesn't happen in my copy of Access.
            If there are no records in the subreport, nothing gets printed.

            What you are asking for can be done by testing the HasData property of the
            report in the subreport control, in the Format event of the main report
            section, or by performing a DLookup() on related records to see if there are
            any, and then toggling the Visible property of the main report section that
            contains the subreport or setting the runtime properties PrintSection and
            MoveLayout. However, it makes no sense to me to do it that way.

            --
            Allen Browne - Microsoft MVP. Perth, Western Australia.
            Tips for Access users - http://allenbrowne.com/tips.html
            Reply to group, rather than allenbrowne at mvps dot org.

            "Tom" <notmy@email.co m> wrote in message
            news:4cGKe.3899 $RZ2.2808@newsr ead3.news.atl.e arthlink.net...[color=blue]
            > The subreport has titles and a logo. It prints when there are no records
            > marked Yes in the IncludeInReport field.
            >
            > Tom
            >
            >
            > "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
            > news:42fae474$0 $32252$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...[color=green]
            >> Tom, I would never consider doing that in code, when you could elimiate
            >> the records in the *query* that the subreport is based on, so that no
            >> code is needed.
            >>
            >> Is there a special reason you wish to use code?
            >>
            >> "Tom" <notmy@email.co m> wrote in message
            >> news:BsAKe.3829 $RZ2.2097@newsr ead3.news.atl.e arthlink.net...[color=darkred]
            >>> Allen,
            >>>
            >>> Thanks for your response!
            >>>
            >>> Please reread my post. I want to know how and where to code to prevent
            >>> printing the subreport when there are no records marked Yes in the
            >>> IncludeInReport field.
            >>>
            >>> Thanks,
            >>>
            >>> Tom
            >>>
            >>>
            >>> "Allen Browne" <AllenBrowne@Se eSig.Invalid> wrote in message
            >>> news:42fab747$0 $32257$5a62ac22 @per-qv1-newsreader-01.iinet.net.au ...
            >>>> Create a query to use as the RecordSource of your subreport.
            >>>>
            >>>> In the Criteria row of the query, under the IncludeInReport field,
            >>>> enter:
            >>>> True
            >>>>
            >>>> "Tom" <notmy@email.co m> wrote in message
            >>>> news:%1tKe.3521 $RZ2.3502@newsr ead3.news.atl.e arthlink.net...
            >>>>>I have a subreport that can contain one or two pictures per page. The
            >>>>>subrepor t is similar to an appendix to the main report. The
            >>>>>recordsour ce contains a field "IncludeInRepor t" (Yes/No) for each
            >>>>>picture record. What code do I use and where does it go to prevent
            >>>>>printing the subreport if there are no picture records marked "Yes" in
            >>>>>the "IncludeInRepor t" field?[/color][/color][/color]


            Comment

            Working...