Printing Multiple Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dancole42@gmail.com

    #1

    Printing Multiple Forms

    I want to create a button that will print multiple forms. Each form is
    a list of various orders, and there are three separate forms:

    -Standard Orders
    -Rush Orders
    -VIP Rush Orders

    Each is based off its own query.

    For certain company reasons, each order type (Standard, Rush, VIP
    Rush) MUST be its own separate form.

    Creating a button that will print all three is easy.

    What I want is a button that will only print forms if they have data
    on them. For example, if there are Standard Orders and Rush Orders,
    but NO VIP Orders, I only want the first two forms printed.

    I'm sure there's a simple solution, but I'm self-taught and not sure
    what to do!

    Thanks!

  • storrboy

    #2
    Re: Printing Multiple Forms


    I would recommend printing reports instead. One of the report events
    is OnNoData. If the query the report is based on does not contain
    records, printing can be canceled. In a button click event use the
    OpenReport method of DoCmd to print them you'd include one line for
    each report to print...

    DoCmd.OpenRepor t "[reportName]", acViewNormal [or acViewPreview],
    [Filter], [Where]

    In the OnNoData event of the report enter Cancel=True.

    Comment

    • dancole42@gmail.com

      #3
      Re: Printing Multiple Forms

      On Mar 19, 2:22 pm, "storrboy" <storr...@sympa tico.cawrote:
      I would recommend printing reports instead. One of the report events
      is OnNoData. If the query the report is based on does not contain
      records, printing can be canceled. In a button click event use the
      OpenReport method of DoCmd to print them you'd include one line for
      each report to print...
      >
      DoCmd.OpenRepor t "[reportName]", acViewNormal [or acViewPreview],
      [Filter], [Where]
      >
      In the OnNoData event of the report enter Cancel=True.
      I've been working on forms all day. I of course meant to say
      reports :)

      Thanks!

      Comment

      • dancole42@gmail.com

        #4
        Re: Printing Multiple Forms

        On Mar 19, 2:22 pm, "storrboy" <storr...@sympa tico.cawrote:
        I would recommend printing reports instead. One of the report events
        is OnNoData. If the query the report is based on does not contain
        records, printing can be canceled. In a button click event use the
        OpenReport method of DoCmd to print them you'd include one line for
        each report to print...
        >
        DoCmd.OpenRepor t "[reportName]", acViewNormal [or acViewPreview],
        [Filter], [Where]
        >
        In the OnNoData event of the report enter Cancel=True.
        So I've got a button that does:

        DoCmd.OpenRepor t "Standard", acViewPreview
        DoCmd.OpenRepor t "Rush", acViewPreview
        DoCmd.OpenRepor t "VIP Rush", acViewPreview

        Each form has the OnNoData event set to "Cancel = True"

        However, the problem here is that if either of the first two reports
        are empty, it cancels the operation and I get a 2501 runtime error
        that says "The OpenReport action was canceled." Which makes sense,
        since the program thinks the whole thing is being cancelled.

        How can I get around this? thanks!

        Comment

        • Rick Brandt

          #5
          Re: Printing Multiple Forms

          <dancole42@gmai l.comwrote in message
          news:1174400784 .308883.12030@n 76g2000hsh.goog legroups.com...
          On Mar 19, 2:22 pm, "storrboy" <storr...@sympa tico.cawrote:
          >I would recommend printing reports instead. One of the report events
          >is OnNoData. If the query the report is based on does not contain
          >records, printing can be canceled. In a button click event use the
          >OpenReport method of DoCmd to print them you'd include one line for
          >each report to print...
          >>
          >DoCmd.OpenRepo rt "[reportName]", acViewNormal [or acViewPreview],
          >[Filter], [Where]
          >>
          >In the OnNoData event of the report enter Cancel=True.
          >
          So I've got a button that does:
          >
          DoCmd.OpenRepor t "Standard", acViewPreview
          DoCmd.OpenRepor t "Rush", acViewPreview
          DoCmd.OpenRepor t "VIP Rush", acViewPreview
          >
          Each form has the OnNoData event set to "Cancel = True"
          >
          However, the problem here is that if either of the first two reports
          are empty, it cancels the operation and I get a 2501 runtime error
          that says "The OpenReport action was canceled." Which makes sense,
          since the program thinks the whole thing is being cancelled.
          >
          How can I get around this? thanks!
          Add an error handler to your routine and in that test the Err.Number and ignore
          when it is number 2501.

          On Error GoTo ErrHandler

          (code)

          Egress:
          Exit Sub

          ErrHandler:
          Select Case Err.Number
          Case 2501
          Resume Next
          Case Else
          MsgBox Err.Description
          Resume Egress
          End Select
          End Sub

          --
          Rick Brandt, Microsoft Access MVP
          Email (as appropriate) to...
          RBrandt at Hunter dot com


          Comment

          • DavidB

            #6
            Re: Printing Multiple Forms

            I prefer to have my no data reports print with the detail containing
            text that says something to the effect that no data exists for the
            report rewuested. That way you always get output that is valid.
            Maybe it the auditor side of me (I did audit work for 9 years) but not
            haveing a report generated on no data leaves you to ASS-U-ME that the
            non-generation of the report was the correct event. Setting up an
            invisible label with a solid background on top of all other data in
            the detail that is toggled to visible on no data is one way to skin
            the cat.



            On Mar 20, 10:26 am, dancol...@gmail .com wrote:
            On Mar 19, 2:22 pm, "storrboy" <storr...@sympa tico.cawrote:
            >
            I would recommend printing reports instead. One of the report events
            is OnNoData. If the query the report is based on does not contain
            records, printing can be canceled. In a button click event use the
            OpenReport method of DoCmd to print them you'd include one line for
            each report to print...
            >
            DoCmd.OpenRepor t "[reportName]", acViewNormal [or acViewPreview],
            [Filter], [Where]
            >
            In the OnNoData event of the report enter Cancel=True.
            >
            So I've got a button that does:
            >
            DoCmd.OpenRepor t "Standard", acViewPreview
            DoCmd.OpenRepor t "Rush", acViewPreview
            DoCmd.OpenRepor t "VIP Rush", acViewPreview
            >
            Each form has the OnNoData event set to "Cancel = True"
            >
            However, the problem here is that if either of the first two reports
            are empty, it cancels the operation and I get a 2501 runtime error
            that says "The OpenReport action was canceled." Which makes sense,
            since the program thinks the whole thing is being cancelled.
            >
            How can I get around this? thanks!

            Comment

            Working...