Print a report 3 times with 3 different fields visible

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

    Print a report 3 times with 3 different fields visible

    Hi,

    I have report which I need to print 3 times, but would like to have
    the following headings

    Customer Copy - Print 1
    Accounts Copy - Print 2
    File Copy -Print 3

    I created a macro to print the report three times, but do not know how
    I can display each text field for each print.

    Can anybody point me in the right direction.
  • Salad

    #2
    Re: Print a report 3 times with 3 different fields visible

    Studiotyphoon wrote:
    Hi,
    >
    I have report which I need to print 3 times, but would like to have
    the following headings
    >
    Customer Copy - Print 1
    Accounts Copy - Print 2
    File Copy -Print 3
    >
    I created a macro to print the report three times, but do not know how
    I can display each text field for each print.
    >
    Can anybody point me in the right direction.
    What version of Access are you using? There is an OpenArgs parameter
    you can pass to the report in A2003. Ex:
    DoCmd.OpenRepor t "YourReportName ", , , , , "1"
    DoCmd.OpenRepor t "YourReportName ", , , , , "2"
    DoCmd.OpenRepor t "YourReportName ", , , , , "3"

    The 1,2,3 is the argument. I created a report called Report1. I
    created 2 text boxes; Text1 and Text2. I put Text1 in the report's
    header, visible = False. I put Text2 in the Report footer.

    In Text1 I entered, for the ControlSource in the Data tab,
    =NZ([Reports]![Report1].[OpenArgs],"0")
    as Report1 is the name of the report.

    In Text2 I entered
    =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"
    in the control source.

    Now when I run the report, depending on the argument passed, it prints
    the value I want.

    Fireballs

    Comment

    • Studiotyphoon

      #3
      Re: Print a report 3 times with 3 different fields visible

      On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
      Studiotyphoon wrote:
      Hi,
      >
      I have report which I need to print 3 times, but would like to have
      the following headings
      >
      Customer Copy - Print 1
      Accounts Copy - Print 2
      File Copy -Print 3
      >
      I created a macro to print the report three times, but do not know how
      I can display each text field for each print.
      >
      Can anybody point me in the right direction.
      >
      What version of Access are you using?  There is an OpenArgs parameter
      you can pass to the report in A2003.  Ex:
              DoCmd.OpenRepor t "YourReportName ", , , , , "1"
              DoCmd.OpenRepor t "YourReportName ", , , , , "2"
              DoCmd.OpenRepor t "YourReportName ", , , , , "3"
      >
      The 1,2,3 is the argument.  I created a report called Report1.  I
      created 2 text boxes; Text1 and Text2.  I put Text1 in the report's
      header, visible = False.  I put Text2 in the Report footer.
      >
      In Text1 I entered, for the ControlSource in the Data tab,
              =NZ([Reports]![Report1].[OpenArgs],"0")
      as Report1 is the name of the report.
      >
      In Text2 I entered
              =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"        
      in the control source.
      >
      Now when I run the report, depending on the argument passed, it prints
      the value I want.
      >
      Fireballshttp://www.youtube.com/watch?v=uzkNI4Y IU2o
      Thanks for help so far.

      Running Access 2003, SP2

      But still struggling to get it to work.

      I've added the following into the report under On Open Event
      DoCmd.OpenRepor t "YourReportName ", , , , , "1"
      DoCmd.OpenRepor t "YourReportName ", , , , , "2"
      DoCmd.OpenRepor t "YourReportName ", , , , , "3"
      When I try running the report it comes up with an error against the
      first line of the code.

      Should this code be in the report or Form for the OpenArgs to be used.

      Also see my reply direct to your email.

      Thanks in advance -

      Comment

      • Salad

        #4
        Re: Print a report 3 times with 3 different fields visible

        Studiotyphoon wrote:
        On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
        >
        >>Studiotypho on wrote:
        >>
        >>>Hi,
        >>
        >>>I have report which I need to print 3 times, but would like to have
        >>>the following headings
        >>
        >>>Customer Copy - Print 1
        >>>Accounts Copy - Print 2
        >>>File Copy -Print 3
        >>
        >>>I created a macro to print the report three times, but do not know how
        >>>I can display each text field for each print.
        >>
        >>>Can anybody point me in the right direction.
        >>
        >>What version of Access are you using? There is an OpenArgs parameter
        >>you can pass to the report in A2003. Ex:
        > DoCmd.OpenRepor t "YourReportName ", , , , , "1"
        > DoCmd.OpenRepor t "YourReportName ", , , , , "2"
        > DoCmd.OpenRepor t "YourReportName ", , , , , "3"
        >>
        >>The 1,2,3 is the argument. I created a report called Report1. I
        >>created 2 text boxes; Text1 and Text2. I put Text1 in the report's
        >>header, visible = False. I put Text2 in the Report footer.
        >>
        >>In Text1 I entered, for the ControlSource in the Data tab,
        > =NZ([Reports]![Report1].[OpenArgs],"0")
        >>as Report1 is the name of the report.
        >>
        >>In Text2 I entered
        > =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"
        >>in the control source.
        >>
        >>Now when I run the report, depending on the argument passed, it prints
        >>the value I want.
        >>
        >>Fireballshttp ://www.youtube.com/watch?v=uzkNI4Y IU2o
        >
        >
        Thanks for help so far.
        >
        Running Access 2003, SP2
        >
        But still struggling to get it to work.
        >
        I've added the following into the report under On Open Event
        >
        >
        > DoCmd.OpenRepor t "YourReportName ", , , , , "1"
        > DoCmd.OpenRepor t "YourReportName ", , , , , "2"
        > DoCmd.OpenRepor t "YourReportName ", , , , , "3"
        >
        >
        When I try running the report it comes up with an error against the
        first line of the code.
        I don't use macros. I checked the Macro builder and there's no OpenArgs
        capability with them. I suppose you could use RunCode and in a code
        module put the OpenReport lines in the sub.

        Did you change "YourReportName " to the name of your report?
        Should this code be in the report or Form for the OpenArgs to be used.
        Usually I call reports from a form. I might have a command button
        CommandReport with a caption of "Report". In the OnClick event I would
        have those 3 lines. I would not have them in the Report's module.
        >
        Also see my reply direct to your email.
        I don't think it made it. Sald may mix with oil and vinegar but there's
        not such email address as far as I know.

        Remember, I created a text box in the Report header band. I have
        =NZ([Reports]![Report1].[OpenArgs],"0")
        as the Control source (under data tab of property sheet). You need to
        change Report1 to your report's name.


        In the footer band I put another textbox at the bottom to print the message.
        =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
        You need to change Text1 to the name of the Textbox in the Report header.
        >
        Thanks in advance -
        >
        Here's another thing you could do. Forget the first textbox...put the
        second text box at the footer. Now open the code module for the report
        and put this code into it.

        Private Function GetCopyText() As String
        'if no argument passed default to "File". Press F1
        'on the word NZ for help if necessary.
        Select Case NZ(Me.OpenArgs, 3)
        Case 1
        GetCopyText = "Customer"
        Case 2
        GetCopyText = "Accounts"
        Case Else
        GetCopyText = "File"
        End Select
        GetCopyText = GetCopyText & " Copy - Print "
        GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
        End Function

        Now in the ControlSource for the textbox in the report's page footer enter
        =GetCopyText()
        This will call the function GetCopyText and print the result in the footer.

        Either way works.

        Feels Good

        Comment

        • Studiotyphoon

          #5
          Re: Print a report 3 times with 3 different fields visible

          On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
          Studiotyphoon wrote:
          On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
          >
          >Studiotyphoo n wrote:
          >
          >>Hi,
          >
          >>I have report which I need to print 3 times, but would like to have
          >>the following headings
          >
          >>Customer Copy - Print 1
          >>Accounts Copy - Print 2
          >>File Copy -Print 3
          >
          >>I created a macro to print the report three times, but do not know how
          >>I can display each text field for each print.
          >
          >>Can anybody point me in the right direction.
          >
          >What version of Access are you using?  There is an OpenArgs parameter
          >you can pass to the report in A2003.  Ex:
                 DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                 DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                 DoCmd.OpenRepor t "YourReportName ", , , , , "3"
          >
          >The 1,2,3 is the argument.  I created a report called Report1.  I
          >created 2 text boxes; Text1 and Text2.  I put Text1 in the report's
          >header, visible = False.  I put Text2 in the Report footer.
          >
          >In Text1 I entered, for the ControlSource in the Data tab,
                 =NZ([Reports]![Report1].[OpenArgs],"0")
          >as Report1 is the name of the report.
          >
          >In Text2 I entered
                 =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"        
          >in the control source.
          >
          >Now when I run the report, depending on the argument passed, it prints
          >the value I want.
          >
          >Fireballshtt p://www.youtube.com/watch?v=uzkNI4Y IU2o
          >
          Thanks for help so far.
          >
          Running Access 2003, SP2
          >
          But still struggling to get it to work.
          >
          I've added the following into the report under On Open Event
          >
                 DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                 DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                 DoCmd.OpenRepor t "YourReportName ", , , , , "3"
          >
          When I try running the report it comes up with an error against the
          first line of the code.
          >
          I don't use macros.  I checked the Macro builder and there's no OpenArgs
          capability with them.  I suppose you could use RunCode and in a code
          module put the OpenReport lines in the sub.
          >
          Did you change "YourReportName " to the name of your report?
          >
          Should this code be in the report or Form for the OpenArgs to be used.
          >
          Usually I call reports from a form.  I might have a command button
          CommandReport with a caption of "Report".  In the OnClick event I would
          have those 3 lines.  I would not have them in the Report's module.
          >
          >
          >
          Also see my reply direct to your email.
          >
          I don't think it made it.  Sald may mix with oil and vinegar but there's
          not such email address as far as I know.
          >
          Remember, I created a text box in the Report header band.  I have
                  =NZ([Reports]![Report1].[OpenArgs],"0")
          as the Control source (under data tab of property sheet).  You need to
          change Report1 to your report's name.
          >
          In the footer band I put another textbox at the bottom to print the message.
             =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
          You need to change Text1 to the name of the Textbox in the Report header.
          >
          >
          >
          Thanks in advance -
          >
          Here's another thing you could do.  Forget the first textbox...put the
          second text box at the footer.  Now open the code module for the report
          and put this code into it.
          >
          Private Function GetCopyText() As String
                  'if no argument passed default to "File".  Press F1
                  'on the word NZ for help if necessary.
                  Select Case NZ(Me.OpenArgs, 3)
                  Case 1
                          GetCopyText = "Customer"
                  Case 2
                          GetCopyText = "Accounts"
                  Case Else
                          GetCopyText = "File"
                  End Select
                  GetCopyText = GetCopyText & " Copy - Print "
                  GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
          End Function
          >
          Now in the ControlSource for the textbox in the report's page footer enter
                  =GetCopyText()
          This will call the function GetCopyText and print the result in the footer..
          >
          Either way works.
          >
          Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1- Hide quotedtext -
          >
          - Show quoted text -
          Thanks for your help.

          I moved the the lines of code to the button on the Form and it
          generates the printouts.

          The query I've generated prompts the user to enter an invoice number,
          to gather the information for the report.
          When I print invoice, the reports are generated but I have to enter
          the invoice number three times.

          Do you know how I can reduce this to entering only once ?

          Thanks again.

          Comment

          • Salad

            #6
            Re: Print a report 3 times with 3 different fields visible

            Studiotyphoon wrote:
            On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
            >
            >>Studiotypho on wrote:
            >>
            >>>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
            >>
            >>>>Studiotypho on wrote:
            >>
            >>>>>Hi,
            >>
            >>>>>I have report which I need to print 3 times, but would like to have
            >>>>>the following headings
            >>
            >>>>>Customer Copy - Print 1
            >>>>>Accounts Copy - Print 2
            >>>>>File Copy -Print 3
            >>
            >>>>>I created a macro to print the report three times, but do not know how
            >>>>>I can display each text field for each print.
            >>
            >>>>>Can anybody point me in the right direction.
            >>
            >>>>What version of Access are you using? There is an OpenArgs parameter
            >>>>you can pass to the report in A2003. Ex:
            >>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
            >>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
            >>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
            >>
            >>>>The 1,2,3 is the argument. I created a report called Report1. I
            >>>>created 2 text boxes; Text1 and Text2. I put Text1 in the report's
            >>>>header, visible = False. I put Text2 in the Report footer.
            >>
            >>>>In Text1 I entered, for the ControlSource in the Data tab,
            >>> =NZ([Reports]![Report1].[OpenArgs],"0")
            >>>>as Report1 is the name of the report.
            >>
            >>>>In Text2 I entered
            >>> =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"
            >>>>in the control source.
            >>
            >>>>Now when I run the report, depending on the argument passed, it prints
            >>>>the value I want.
            >>
            >>>>Fireballsht tp://www.youtube.com/watch?v=uzkNI4Y IU2o
            >>
            >>>Thanks for help so far.
            >>
            >>>Running Access 2003, SP2
            >>
            >>>But still struggling to get it to work.
            >>
            >>>I've added the following into the report under On Open Event
            >>
            >>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
            >>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
            >>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
            >>
            >>>When I try running the report it comes up with an error against the
            >>>first line of the code.
            >>
            >>I don't use macros. I checked the Macro builder and there's no OpenArgs
            >>capability with them. I suppose you could use RunCode and in a code
            >>module put the OpenReport lines in the sub.
            >>
            >>Did you change "YourReportName " to the name of your report?
            >>
            >>
            >>>Should this code be in the report or Form for the OpenArgs to be used.
            >>
            >>Usually I call reports from a form. I might have a command button
            >>CommandRepo rt with a caption of "Report". In the OnClick event I would
            >>have those 3 lines. I would not have them in the Report's module.
            >>
            >>
            >>
            >>
            >>>Also see my reply direct to your email.
            >>
            >>I don't think it made it. Sald may mix with oil and vinegar but there's
            >>not such email address as far as I know.
            >>
            >>Remember, I created a text box in the Report header band. I have
            > =NZ([Reports]![Report1].[OpenArgs],"0")
            >>as the Control source (under data tab of property sheet). You need to
            >>change Report1 to your report's name.
            >>
            >>In the footer band I put another textbox at the bottom to print the message.
            > =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
            >>You need to change Text1 to the name of the Textbox in the Report header.
            >>
            >>
            >>
            >>
            >>>Thanks in advance -
            >>
            >>Here's another thing you could do. Forget the first textbox...put the
            >>second text box at the footer. Now open the code module for the report
            >>and put this code into it.
            >>
            >>Private Function GetCopyText() As String
            > 'if no argument passed default to "File". Press F1
            > 'on the word NZ for help if necessary.
            > Select Case NZ(Me.OpenArgs, 3)
            > Case 1
            > GetCopyText = "Customer"
            > Case 2
            > GetCopyText = "Accounts"
            > Case Else
            > GetCopyText = "File"
            > End Select
            > GetCopyText = GetCopyText & " Copy - Print "
            > GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
            >>End Function
            >>
            >>Now in the ControlSource for the textbox in the report's page footer enter
            > =GetCopyText()
            >>This will call the function GetCopyText and print the result in the footer.
            >>
            >>Either way works.
            >>
            >>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1- Hide quoted text -
            >>
            >>- Show quoted text -
            >
            >
            Thanks for your help.
            >
            I moved the the lines of code to the button on the Form and it
            generates the printouts.
            >
            The query I've generated prompts the user to enter an invoice number,
            to gather the information for the report.
            When I print invoice, the reports are generated but I have to enter
            the invoice number three times.
            >
            Do you know how I can reduce this to entering only once ?
            >
            Thanks again.
            The easist way I know to do that is to create a TextBox on the form and
            allow the user to enter an invoice number. Then when you print the
            report by pressing the Report command button do something like
            Private Sub CommandReport_C lick()
            If Not IsNull(Me.Invoi ceNumber) Then
            ...print report(s)
            Else
            msgbox "Please supply an invoice number."
            Me.InvoiceNumbe r.SetFocus
            Endif
            End Sub

            Now lets say that this form is called Form1. Open up the query in
            design mode and under the InvoiceNumber column in the Criteria row enter
            Forms!Form1!Inv oiceNumber
            You'd want to change Form1 to whatever formname you have.

            Now what happens if you print all three reports and the first one prints
            OK and then jams on the 2nd or 3rd report. You could create an Option
            group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
            Default value (under Data tab) is 0, name of option group is Frame1.
            Then when you print your code could be something like
            Private Sub CommandReport_C lick()
            Dim intFor As Integer
            If Not IsNull(Me.Invoi ceNumber) Then
            If Me.Frame1 <0 then
            Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
            Else
            For intFor = 1 to 3
            Docmd.OpenRepor t "YourReport",,, ,,intFor
            Next
            Else
            msgbox "Please supply an invoice number."
            Me.InvoiceNumbe r.SetFocus
            Endif
            End Sub

            Destination Unknown

            Comment

            • Studiotyphoon

              #7
              Re: Print a report 3 times with 3 different fields visible

              On Apr 21, 10:49 pm, Salad <o...@vinegar.c omwrote:
              Studiotyphoon wrote:
              On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
              >
              >Studiotyphoo n wrote:
              >
              >>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
              >
              >>>Studiotyphoo n wrote:
              >
              >>>>Hi,
              >
              >>>>I have report which I need to print 3 times, but would like to have
              >>>>the following headings
              >
              >>>>Customer Copy - Print 1
              >>>>Accounts Copy - Print 2
              >>>>File Copy -Print 3
              >
              >>>>I created a macro to print the report three times, but do not know how
              >>>>I can display each text field for each print.
              >
              >>>>Can anybody point me in the right direction.
              >
              >>>What version of Access are you using?  There is an OpenArgs parameter
              >>>you can pass to the report in A2003.  Ex:
              >>      DoCmd.OpenRepor t "YourReportName ", , , , , "1"
              >>      DoCmd.OpenRepor t "YourReportName ", , , , , "2"
              >>      DoCmd.OpenRepor t "YourReportName ", , , , , "3"
              >
              >>>The 1,2,3 is the argument.  I created a report called Report1.  I
              >>>created 2 text boxes; Text1 and Text2.  I put Text1 in the report's
              >>>header, visible = False.  I put Text2 in the Report footer.
              >
              >>>In Text1 I entered, for the ControlSource in the Data tab,
              >>      =NZ([Reports]![Report1].[OpenArgs],"0")
              >>>as Report1 is the name of the report.
              >
              >>>In Text2 I entered
              >>      =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"        
              >>>in the control source.
              >
              >>>Now when I run the report, depending on the argument passed, it prints
              >>>the value I want.
              >
              >>>Fireballshtt p://www.youtube.com/watch?v=uzkNI4Y IU2o
              >
              >>Thanks for help so far.
              >
              >>Running Access 2003, SP2
              >
              >>But still struggling to get it to work.
              >
              >>I've added the following into the report under On Open Event
              >
              >>      DoCmd.OpenRepor t "YourReportName ", , , , , "1"
              >>      DoCmd.OpenRepor t "YourReportName ", , , , , "2"
              >>      DoCmd.OpenRepor t "YourReportName ", , , , , "3"
              >
              >>When I try running the report it comes up with an error against the
              >>first line of the code.
              >
              >I don't use macros.  I checked the Macro builder and there's no OpenArgs
              >capability with them.  I suppose you could use RunCode and in a code
              >module put the OpenReport lines in the sub.
              >
              >Did you change "YourReportName " to the name of your report?
              >
              >>Should this code be in the report or Form for the OpenArgs to be used.
              >
              >Usually I call reports from a form.  I might have a command button
              >CommandRepor t with a caption of "Report".  In the OnClick event I would
              >have those 3 lines.  I would not have them in the Report's module.
              >
              >>Also see my reply direct to your email.
              >
              >I don't think it made it.  Sald may mix with oil and vinegar but there's
              >not such email address as far as I know.
              >
              >Remember, I created a text box in the Report header band.  I have
                     =NZ([Reports]![Report1].[OpenArgs],"0")
              >as the Control source (under data tab of property sheet).  You need to
              >change Report1 to your report's name.
              >
              >In the footer band I put another textbox at the bottom to print the message.
                =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
              >You need to change Text1 to the name of the Textbox in the Report header..
              >
              >>Thanks in advance -
              >
              >Here's another thing you could do.  Forget the first textbox...put the
              >second text box at the footer.  Now open the code module for the report
              >and put this code into it.
              >
              >Private Function GetCopyText() As String
                     'if no argument passed default to "File".  Press F1
                     'on the word NZ for help if necessary.
                     Select Case NZ(Me.OpenArgs, 3)
                     Case 1
                             GetCopyText = "Customer"
                     Case 2
                             GetCopyText = "Accounts"
                     Case Else
                             GetCopyText = "File"
                     End Select
                     GetCopyText = GetCopyText & " Copy - Print "
                     GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
              >End Function
              >
              >Now in the ControlSource for the textbox in the report's page footer enter
                     =GetCopyText()
              >This will call the function GetCopyText and print the result in the footer.
              >
              >Either way works.
              >
              >Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1-Hide quoted text -
              >
              >- Show quoted text -
              >
              Thanks for your help.
              >
              I moved the the lines of code to the button on the Form and it
              generates the printouts.
              >
              The query I've generated prompts the user to enter an invoice number,
              to gather the information for the report.
              When I print invoice, the reports are generated but I have to enter
              the invoice number three times.
              >
              Do you know how I can reduce this to entering only once ?
              >
              Thanks again.
              >
              The easist way I know to do that is to create a TextBox on the form and
              allow the user to enter an invoice number.  Then when you print the
              report by pressing the Report command button do something like
                 Private Sub CommandReport_C lick()
                      If Not IsNull(Me.Invoi ceNumber) Then
                              ...print report(s)
                      Else
                              msgbox "Please supply an invoice number."
                              Me.InvoiceNumbe r.SetFocus
                      Endif
                 End Sub
              >
              Now lets say that this form is called Form1.  Open up the query in
              design mode and under the InvoiceNumber column in the Criteria row enter
                      Forms!Form1!Inv oiceNumber
              You'd want to change Form1 to whatever formname you have.
              >
              Now what happens if you print all three reports and the first one prints
              OK and then jams on the 2nd or 3rd report.  You could create an Option
              group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
              Default value (under Data tab) is 0, name of option group is Frame1.
              Then when you print your code could be something like
                 Private Sub CommandReport_C lick()
                      Dim intFor As Integer
                      If Not IsNull(Me.Invoi ceNumber) Then
                              If Me.Frame1 <0 then
                                      Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
                              Else
                                For intFor = 1 to 3
                                      Docmd.OpenRepor t "YourReport",,, ,,intFor
                                Next                          
                      Else
                              msgbox "Please supply an invoice number."
                              Me.InvoiceNumbe r.SetFocus
                      Endif
                 End Sub
              >
              Destination Unknownhttp://www.youtube.com/watch?v=uitCCcL AtGw- Hide quoted text -
              >
              - Show quoted text -
              Thank you for your help.

              It has been gratelly appreciated.

              Comment

              • Studiotyphoon

                #8
                Re: Print a report 3 times with 3 different fields visible

                On Apr 22, 11:07 am, Studiotyphoon <a...@pidesign. co.ukwrote:
                On Apr 21, 10:49 pm, Salad <o...@vinegar.c omwrote:
                >
                >
                >
                >
                >
                Studiotyphoon wrote:
                On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
                >
                >>Studiotypho on wrote:
                >
                >>>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
                >
                >>>>Studiotypho on wrote:
                >
                >>>>>Hi,
                >
                >>>>>I have report which I need to print 3 times, but would like to have
                >>>>>the following headings
                >
                >>>>>Customer Copy - Print 1
                >>>>>Accounts Copy - Print 2
                >>>>>File Copy -Print 3
                >
                >>>>>I created a macro to print the report three times, but do not know how
                >>>>>I can display each text field for each print.
                >
                >>>>>Can anybody point me in the right direction.
                >
                >>>>What version of Access are you using?  There is an OpenArgs parameter
                >>>>you can pass to the report in A2003.  Ex:
                >>>      DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                >>>      DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                >>>      DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                >
                >>>>The 1,2,3 is the argument.  I created a report called Report1.  I
                >>>>created 2 text boxes; Text1 and Text2.  I put Text1 in the report's
                >>>>header, visible = False.  I put Text2 in the Report footer.
                >
                >>>>In Text1 I entered, for the ControlSource in the Data tab,
                >>>      =NZ([Reports]![Report1].[OpenArgs],"0")
                >>>>as Report1 is the name of the report.
                >
                >>>>In Text2 I entered
                >>>      =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"        
                >>>>in the control source.
                >
                >>>>Now when I run the report, depending on the argument passed, it prints
                >>>>the value I want.
                >
                >>>>Fireballsht tp://www.youtube.com/watch?v=uzkNI4Y IU2o
                >
                >>>Thanks for help so far.
                >
                >>>Running Access 2003, SP2
                >
                >>>But still struggling to get it to work.
                >
                >>>I've added the following into the report under On Open Event
                >
                >>>      DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                >>>      DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                >>>      DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                >
                >>>When I try running the report it comes up with an error against the
                >>>first line of the code.
                >
                >>I don't use macros.  I checked the Macro builder and there's no OpenArgs
                >>capability with them.  I suppose you could use RunCode and in a code
                >>module put the OpenReport lines in the sub.
                >
                >>Did you change "YourReportName " to the name of your report?
                >
                >>>Should this code be in the report or Form for the OpenArgs to be used..
                >
                >>Usually I call reports from a form.  I might have a command button
                >>CommandRepo rt with a caption of "Report".  In the OnClick event I would
                >>have those 3 lines.  I would not have them in the Report's module.
                >
                >>>Also see my reply direct to your email.
                >
                >>I don't think it made it.  Sald may mix with oil and vinegar but there's
                >>not such email address as far as I know.
                >
                >>Remember, I created a text box in the Report header band.  I have
                >       =NZ([Reports]![Report1].[OpenArgs],"0")
                >>as the Control source (under data tab of property sheet).  You need to
                >>change Report1 to your report's name.
                >
                >>In the footer band I put another textbox at the bottom to print the message.
                >  =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
                >>You need to change Text1 to the name of the Textbox in the Report header.
                >
                >>>Thanks in advance -
                >
                >>Here's another thing you could do.  Forget the first textbox...put the
                >>second text box at the footer.  Now open the code module for the report
                >>and put this code into it.
                >
                >>Private Function GetCopyText() As String
                >       'if no argument passed default to "File".  Press F1
                >       'on the word NZ for help if necessary.
                >       Select Case NZ(Me.OpenArgs, 3)
                >       Case 1
                >               GetCopyText = "Customer"
                >       Case 2
                >               GetCopyText = "Accounts"
                >       Case Else
                >               GetCopyText = "File"
                >       End Select
                >       GetCopyText = GetCopyText & " Copy - Print "
                >       GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
                >>End Function
                >
                >>Now in the ControlSource for the textbox in the report's page footer enter
                >       =GetCopyText()
                >>This will call the function GetCopyText and print the result in the footer.
                >
                >>Either way works.
                >
                >>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1-Hidequoted text -
                >
                >>- Show quoted text -
                >
                Thanks for your help.
                >
                I moved the the lines of code to the button on the Form and it
                generates the printouts.
                >
                The query I've generated prompts the user to enter an invoice number,
                to gather the information for the report.
                When I print invoice, the reports are generated but I have to enter
                the invoice number three times.
                >
                Do you know how I can reduce this to entering only once ?
                >
                Thanks again.
                >
                The easist way I know to do that is to create a TextBox on the form and
                allow the user to enter an invoice number.  Then when you print the
                report by pressing the Report command button do something like
                   Private Sub CommandReport_C lick()
                        If Not IsNull(Me.Invoi ceNumber) Then
                                ...print report(s)
                        Else
                                msgbox "Please supply an invoice number."
                                Me.InvoiceNumbe r.SetFocus
                        Endif
                   End Sub
                >
                Now lets say that this form is called Form1.  Open up the query in
                design mode and under the InvoiceNumber column in the Criteria row enter
                        Forms!Form1!Inv oiceNumber
                You'd want to change Form1 to whatever formname you have.
                >
                Now what happens if you print all three reports and the first one prints
                OK and then jams on the 2nd or 3rd report.  You could create an Option
                group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
                Default value (under Data tab) is 0, name of option group is Frame1.
                Then when you print your code could be something like
                   Private Sub CommandReport_C lick()
                        Dim intFor As Integer
                        If Not IsNull(Me.Invoi ceNumber) Then
                                If Me.Frame1 <0 then
                                        Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
                                Else
                                  For intFor = 1 to 3
                                        Docmd.OpenRepor t "YourReport",,, ,,intFor
                                  Next                         
                        Else
                                msgbox "Please supply an invoice number."
                                Me.InvoiceNumbe r.SetFocus
                        Endif
                   End Sub
                >
                Destination Unknownhttp://www.youtube.com/watch?v=uitCCcL AtGw-Hide quoted text -
                >
                - Show quoted text -
                >
                Thank you for your help.
                >
                It has been gratelly appreciated.- Hide quoted text -
                >
                - Show quoted text -
                Hi me again,

                With the code you gave me thought problem sorted.

                For some reason when I put

                Forms!Form1!Inv oiceNumber

                in the criteria, an error occurred invalid syntax regarding the
                expression.

                I changed it to the following based upon the help files but I get a
                request for a parameter value.

                [Forms]![Finance Invoice Form]![Internal ID]

                Any Ideas ?



                Comment

                • Salad

                  #9
                  Re: Print a report 3 times with 3 different fields visible

                  Studiotyphoon wrote:
                  On Apr 22, 11:07 am, Studiotyphoon <a...@pidesign. co.ukwrote:
                  >
                  >>On Apr 21, 10:49 pm, Salad <o...@vinegar.c omwrote:
                  >>
                  >>
                  >>
                  >>
                  >>
                  >>
                  >>>Studiotyphoo n wrote:
                  >>>
                  >>>>On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
                  >>
                  >>>>>Studiotyph oon wrote:
                  >>
                  >>>>>>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
                  >>
                  >>>>>>>Studioty phoon wrote:
                  >>
                  >>>>>>>>Hi,
                  >>
                  >>>>>>>>I have report which I need to print 3 times, but would like to have
                  >>>>>>>>the following headings
                  >>
                  >>>>>>>>Custome r Copy - Print 1
                  >>>>>>>>Account s Copy - Print 2
                  >>>>>>>>File Copy -Print 3
                  >>
                  >>>>>>>>I created a macro to print the report three times, but do not know how
                  >>>>>>>>I can display each text field for each print.
                  >>
                  >>>>>>>>Can anybody point me in the right direction.
                  >>
                  >>>>>>>What version of Access are you using? There is an OpenArgs parameter
                  >>>>>>>you can pass to the report in A2003. Ex:
                  >>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                  >>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                  >>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                  >>
                  >>>>>>>The 1,2,3 is the argument. I created a report called Report1. I
                  >>>>>>>create d 2 text boxes; Text1 and Text2. I put Text1 in the report's
                  >>>>>>>header , visible = False. I put Text2 in the Report footer.
                  >>
                  >>>>>>>In Text1 I entered, for the ControlSource in the Data tab,
                  >>>>>> =NZ([Reports]![Report1].[OpenArgs],"0")
                  >>>>>>>as Report1 is the name of the report.
                  >>
                  >>>>>>>In Text2 I entered
                  >>>>>> =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"
                  >>>>>>>in the control source.
                  >>
                  >>>>>>>Now when I run the report, depending on the argument passed, it prints
                  >>>>>>>the value I want.
                  >>
                  >>>>>>>Fireball shttp://www.youtube.com/watch?v=uzkNI4Y IU2o
                  >>
                  >>>>>>Thanks for help so far.
                  >>
                  >>>>>>Running Access 2003, SP2
                  >>
                  >>>>>>But still struggling to get it to work.
                  >>
                  >>>>>>I've added the following into the report under On Open Event
                  >>
                  >>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                  >>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                  >>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                  >>
                  >>>>>>When I try running the report it comes up with an error against the
                  >>>>>>first line of the code.
                  >>
                  >>>>>I don't use macros. I checked the Macro builder and there's no OpenArgs
                  >>>>>capabili ty with them. I suppose you could use RunCode and in a code
                  >>>>>module put the OpenReport lines in the sub.
                  >>
                  >>>>>Did you change "YourReportName " to the name of your report?
                  >>
                  >>>>>>Should this code be in the report or Form for the OpenArgs to be used.
                  >>
                  >>>>>Usually I call reports from a form. I might have a command button
                  >>>>>CommandRep ort with a caption of "Report". In the OnClick event I would
                  >>>>>have those 3 lines. I would not have them in the Report's module.
                  >>
                  >>>>>>Also see my reply direct to your email.
                  >>
                  >>>>>I don't think it made it. Sald may mix with oil and vinegar but there's
                  >>>>>not such email address as far as I know.
                  >>
                  >>>>>Remember , I created a text box in the Report header band. I have
                  >>>> =NZ([Reports]![Report1].[OpenArgs],"0")
                  >>>>>as the Control source (under data tab of property sheet). You need to
                  >>>>>change Report1 to your report's name.
                  >>
                  >>>>>In the footer band I put another textbox at the bottom to print the message.
                  >>>> =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
                  >>>>>You need to change Text1 to the name of the Textbox in the Report header.
                  >>
                  >>>>>>Thanks in advance -
                  >>
                  >>>>>Here's another thing you could do. Forget the first textbox...put the
                  >>>>>second text box at the footer. Now open the code module for the report
                  >>>>>and put this code into it.
                  >>
                  >>>>>Private Function GetCopyText() As String
                  >>>> 'if no argument passed default to "File". Press F1
                  >>>> 'on the word NZ for help if necessary.
                  >>>> Select Case NZ(Me.OpenArgs, 3)
                  >>>> Case 1
                  >>>> GetCopyText = "Customer"
                  >>>> Case 2
                  >>>> GetCopyText = "Accounts"
                  >>>> Case Else
                  >>>> GetCopyText = "File"
                  >>>> End Select
                  >>>> GetCopyText = GetCopyText & " Copy - Print "
                  >>>> GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
                  >>>>>End Function
                  >>
                  >>>>>Now in the ControlSource for the textbox in the report's page footer enter
                  >>>> =GetCopyText()
                  >>>>>This will call the function GetCopyText and print the result in the footer.
                  >>
                  >>>>>Either way works.
                  >>
                  >>>>>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1-Hidequoted text -
                  >>
                  >>>>>- Show quoted text -
                  >>
                  >>>>Thanks for your help.
                  >>
                  >>>>I moved the the lines of code to the button on the Form and it
                  >>>>generates the printouts.
                  >>
                  >>>>The query I've generated prompts the user to enter an invoice number,
                  >>>>to gather the information for the report.
                  >>>>When I print invoice, the reports are generated but I have to enter
                  >>>>the invoice number three times.
                  >>
                  >>>>Do you know how I can reduce this to entering only once ?
                  >>
                  >>>>Thanks again.
                  >>
                  >>>The easist way I know to do that is to create a TextBox on the form and
                  >>>allow the user to enter an invoice number. Then when you print the
                  >>>report by pressing the Report command button do something like
                  >> Private Sub CommandReport_C lick()
                  >> If Not IsNull(Me.Invoi ceNumber) Then
                  >> ...print report(s)
                  >> Else
                  >> msgbox "Please supply an invoice number."
                  >> Me.InvoiceNumbe r.SetFocus
                  >> Endif
                  >> End Sub
                  >>
                  >>>Now lets say that this form is called Form1. Open up the query in
                  >>>design mode and under the InvoiceNumber column in the Criteria row enter
                  >> Forms!Form1!Inv oiceNumber
                  >>>You'd want to change Form1 to whatever formname you have.
                  >>
                  >>>Now what happens if you print all three reports and the first one prints
                  >>>OK and then jams on the 2nd or 3rd report. You could create an Option
                  >>>group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
                  >>>Default value (under Data tab) is 0, name of option group is Frame1.
                  >>>Then when you print your code could be something like
                  >> Private Sub CommandReport_C lick()
                  >> Dim intFor As Integer
                  >> If Not IsNull(Me.Invoi ceNumber) Then
                  >> If Me.Frame1 <0 then
                  >> Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
                  >> Else
                  >> For intFor = 1 to 3
                  >> Docmd.OpenRepor t "YourReport",,, ,,intFor
                  >> Next
                  >> Else
                  >> msgbox "Please supply an invoice number."
                  >> Me.InvoiceNumbe r.SetFocus
                  >> Endif
                  >> End Sub
                  >>
                  >>>Destinatio n Unknownhttp://www.youtube.com/watch?v=uitCCcL AtGw-Hide quoted text -
                  >>
                  >>>- Show quoted text -
                  >>
                  >>Thank you for your help.
                  >>
                  >>It has been gratelly appreciated.- Hide quoted text -
                  >>
                  >>- Show quoted text -
                  >
                  >
                  Hi me again,
                  >
                  With the code you gave me thought problem sorted.
                  >
                  For some reason when I put
                  >
                  Forms!Form1!Inv oiceNumber
                  >
                  in the criteria, an error occurred invalid syntax regarding the
                  expression.
                  >
                  I changed it to the following based upon the help files but I get a
                  request for a parameter value.
                  >
                  [Forms]![Finance Invoice Form]![Internal ID]
                  >
                  Any Ideas ?
                  >
                  Let's see, select all records from these tables where the invoice number
                  is equal to an invoice number in...a closed form. I wonder what that
                  invoice number is?

                  Are you calling this report form a form's code? Or are you calling it
                  from the report's recordsource?

                  I create form's to call reports. I can then provide options, any that I
                  like, and giving users choices to filter the report, direct the output,
                  exit without printing, etc.

                  Comment

                  • Studiotyphoon

                    #10
                    Re: Print a report 3 times with 3 different fields visible

                    On Apr 22, 11:35 pm, Salad <o...@vinegar.c omwrote:
                    Studiotyphoon wrote:
                    On Apr 22, 11:07 am, Studiotyphoon <a...@pidesign. co.ukwrote:
                    >
                    >On Apr 21, 10:49 pm, Salad <o...@vinegar.c omwrote:
                    >
                    >>Studiotypho on wrote:
                    >
                    >>>On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
                    >
                    >>>>Studiotypho on wrote:
                    >
                    >>>>>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
                    >
                    >>>>>>Studiotyp hoon wrote:
                    >
                    >>>>>>>Hi,
                    >
                    >>>>>>>I have report which I need to print 3 times, but would like to have
                    >>>>>>>the following headings
                    >
                    >>>>>>>Custom er Copy - Print 1
                    >>>>>>>Accoun ts Copy - Print 2
                    >>>>>>>File Copy -Print 3
                    >
                    >>>>>>>I created a macro to print the report three times, but do not knowhow
                    >>>>>>>I can display each text field for each print.
                    >
                    >>>>>>>Can anybody point me in the right direction.
                    >
                    >>>>>>What version of Access are you using?  There is an OpenArgs parameter
                    >>>>>>you can pass to the report in A2003.  Ex:
                    >>>>>     DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                    >>>>>     DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                    >>>>>     DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                    >
                    >>>>>>The 1,2,3 is the argument.  I created a report called Report1.  I
                    >>>>>>created 2 text boxes; Text1 and Text2.  I put Text1 in the report's
                    >>>>>>header, visible = False.  I put Text2 in the Report footer.
                    >
                    >>>>>>In Text1 I entered, for the ControlSource in the Data tab,
                    >>>>>     =NZ([Reports]![Report1].[OpenArgs],"0")
                    >>>>>>as Report1 is the name of the report.
                    >
                    >>>>>>In Text2 I entered
                    >>>>>     =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"        
                    >>>>>>in the control source.
                    >
                    >>>>>>Now when I run the report, depending on the argument passed, it prints
                    >>>>>>the value I want.
                    >
                    >>>>>>Fireballs http://www.youtube.com/watch?v=uzkNI4Y IU2o
                    >
                    >>>>>Thanks for help so far.
                    >
                    >>>>>Running Access 2003, SP2
                    >
                    >>>>>But still struggling to get it to work.
                    >
                    >>>>>I've added the following into the report under On Open Event
                    >
                    >>>>>     DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                    >>>>>     DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                    >>>>>     DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                    >
                    >>>>>When I try running the report it comes up with an error against the
                    >>>>>first line of the code.
                    >
                    >>>>I don't use macros.  I checked the Macro builder and there's no OpenArgs
                    >>>>capabilit y with them.  I suppose you could use RunCode and in a code
                    >>>>module put the OpenReport lines in the sub.
                    >
                    >>>>Did you change "YourReportName " to the name of your report?
                    >
                    >>>>>Should this code be in the report or Form for the OpenArgs to be used.
                    >
                    >>>>Usually I call reports from a form.  I might have a command button
                    >>>>CommandRepo rt with a caption of "Report".  In the OnClick event I would
                    >>>>have those 3 lines.  I would not have them in the Report's module.
                    >
                    >>>>>Also see my reply direct to your email.
                    >
                    >>>>I don't think it made it.  Sald may mix with oil and vinegar but there's
                    >>>>not such email address as far as I know.
                    >
                    >>>>Remember, I created a text box in the Report header band.  I have
                    >>>      =NZ([Reports]![Report1].[OpenArgs],"0")
                    >>>>as the Control source (under data tab of property sheet).  You needto
                    >>>>change Report1 to your report's name.
                    >
                    >>>>In the footer band I put another textbox at the bottom to print the message.
                    >>> =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
                    >>>>You need to change Text1 to the name of the Textbox in the Report header.
                    >
                    >>>>>Thanks in advance -
                    >
                    >>>>Here's another thing you could do.  Forget the first textbox...put the
                    >>>>second text box at the footer.  Now open the code module for the report
                    >>>>and put this code into it.
                    >
                    >>>>Private Function GetCopyText() As String
                    >>>      'if no argument passed default to "File".  Press F1
                    >>>      'on the word NZ for help if necessary.
                    >>>      Select Case NZ(Me.OpenArgs, 3)
                    >>>      Case 1
                    >>>              GetCopyText = "Customer"
                    >>>      Case 2
                    >>>              GetCopyText = "Accounts"
                    >>>      Case Else
                    >>>              GetCopyText = "File"
                    >>>      End Select
                    >>>      GetCopyText = GetCopyText & " Copy - Print "
                    >>>      GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
                    >>>>End Function
                    >
                    >>>>Now in the ControlSource for the textbox in the report's page footer enter
                    >>>      =GetCopyText()
                    >>>>This will call the function GetCopyText and print the result in the footer.
                    >
                    >>>>Either way works.
                    >
                    >>>>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1-Hidequotedtext -
                    >
                    >>>>- Show quoted text -
                    >
                    >>>Thanks for your help.
                    >
                    >>>I moved the the lines of code to the button on the Form and it
                    >>>generates the printouts.
                    >
                    >>>The query I've generated prompts the user to enter an invoice number,
                    >>>to gather the information for the report.
                    >>>When I print invoice, the reports are generated but I have to enter
                    >>>the invoice number three times.
                    >
                    >>>Do you know how I can reduce this to entering only once ?
                    >
                    >>>Thanks again.
                    >
                    >>The easist way I know to do that is to create a TextBox on the form and
                    >>allow the user to enter an invoice number.  Then when you print the
                    >>report by pressing the Report command button do something like
                    >  Private Sub CommandReport_C lick()
                    >       If Not IsNull(Me.Invoi ceNumber) Then
                    >               ...print report(s)
                    >       Else
                    >               msgbox "Please supply an invoice number.."
                    >               Me.InvoiceNumbe r.SetFocus
                    >       Endif
                    >  End Sub
                    >
                    >>Now lets say that this form is called Form1.  Open up the query in
                    >>design mode and under the InvoiceNumber column in the Criteria row enter
                    >       Forms!Form1!Inv oiceNumber
                    >>You'd want to change Form1 to whatever formname you have.
                    >
                    >>Now what happens if you print all three reports and the first one prints
                    >>OK and then jams on the 2nd or 3rd report.  You could create an Option
                    >>group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File..
                    >>Default value (under Data tab) is 0, name of option group is Frame1.
                    >>Then when you print your code could be something like
                    >  Private Sub CommandReport_C lick()
                    >       Dim intFor As Integer
                    >       If Not IsNull(Me.Invoi ceNumber) Then
                    >               If Me.Frame1 <0 then
                    >                       Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
                    >               Else
                    >                 For intFor = 1 to 3
                    >                       Docmd.OpenRepor t "YourReport",,, ,,intFor
                    >                 Next                          
                    >       Else
                    >               msgbox "Please supply an invoice number.."
                    >               Me.InvoiceNumbe r.SetFocus
                    >       Endif
                    >  End Sub
                    >
                    >>Destination Unknownhttp://www.youtube.com/watch?v=uitCCcL AtGw-Hidequoted text -
                    >
                    >>- Show quoted text -
                    >
                    >Thank you for your help.
                    >
                    >It has been gratelly appreciated.- Hide quoted text -
                    >
                    >- Show quoted text -
                    >
                    Hi me again,
                    >
                    With the code you gave me thought problem sorted.
                    >
                    For some reason when I put
                    >
                    Forms!Form1!Inv oiceNumber
                    >
                    in the criteria, an error occurred  invalid syntax regarding the
                    expression.
                    >
                    I changed it to the following based upon the help files but I get a
                    request for a parameter value.
                    >
                    [Forms]![Finance Invoice Form]![Internal ID]
                    >
                    Any Ideas ?
                    >
                    Let's see, select all records from these tables where the invoice number
                    is equal to an invoice number in...a closed form.  I wonder what that
                    invoice number is?
                    >
                    Are you calling this report form a form's code?  Or are you calling it
                    from the report's recordsource?
                    >
                    I create form's to call reports.  I can then provide options, any that I
                    like, and giving users choices to filter the report, direct the output,
                    exit without printing, etc.- Hide quoted text -
                    >
                    - Show quoted text -
                    I have a Subform called invoicing, which is then linked to a header
                    Form.

                    I placed your code in the subform Invoicing and without entering the
                    code into the query, the report prints out all invoices it can find,
                    and three times as per the above code.

                    it would be fine if I wanted to print all invoices, but when I only
                    want to select the current invoice record using the code in the
                    criteria, I get a data mismatch when I try to print.

                    I can email a copy of the Database for you to look at and point me in
                    the right direction, if it help resolve the problem.

                    Thanks

                    Comment

                    • Salad

                      #11
                      Re: Print a report 3 times with 3 different fields visible

                      Studiotyphoon wrote:
                      On Apr 22, 11:35 pm, Salad <o...@vinegar.c omwrote:
                      >
                      >>Studiotypho on wrote:
                      >>
                      >>>On Apr 22, 11:07 am, Studiotyphoon <a...@pidesign. co.ukwrote:
                      >>
                      >>>>On Apr 21, 10:49 pm, Salad <o...@vinegar.c omwrote:
                      >>
                      >>>>>Studiotyph oon wrote:
                      >>
                      >>>>>>On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
                      >>
                      >>>>>>>Studioty phoon wrote:
                      >>
                      >>>>>>>>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
                      >>
                      >>>>>>>>>Studio typhoon wrote:
                      >>
                      >>>>>>>>>>Hi,
                      >>
                      >>>>>>>>>>I have report which I need to print 3 times, but would like to have
                      >>>>>>>>>>the following headings
                      >>
                      >>>>>>>>>>Custo mer Copy - Print 1
                      >>>>>>>>>>Accou nts Copy - Print 2
                      >>>>>>>>>>Fil e Copy -Print 3
                      >>
                      >>>>>>>>>>I created a macro to print the report three times, but do not know how
                      >>>>>>>>>>I can display each text field for each print.
                      >>
                      >>>>>>>>>>Can anybody point me in the right direction.
                      >>
                      >>>>>>>>>What version of Access are you using? There is an OpenArgs parameter
                      >>>>>>>>>you can pass to the report in A2003. Ex:
                      >>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                      >>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                      >>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                      >>
                      >>>>>>>>>The 1,2,3 is the argument. I created a report called Report1. I
                      >>>>>>>>>create d 2 text boxes; Text1 and Text2. I put Text1 in the report's
                      >>>>>>>>>header , visible = False. I put Text2 in the Report footer.
                      >>
                      >>>>>>>>>In Text1 I entered, for the ControlSource in the Data tab,
                      >>>>>>>> =NZ([Reports]![Report1].[OpenArgs],"0")
                      >>>>>>>>>as Report1 is the name of the report.
                      >>
                      >>>>>>>>>In Text2 I entered
                      >>>>>>>> =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"
                      >>>>>>>>>in the control source.
                      >>
                      >>>>>>>>>Now when I run the report, depending on the argument passed, it prints
                      >>>>>>>>>the value I want.
                      >>
                      >>>>>>>>>Fireba llshttp://www.youtube.com/watch?v=uzkNI4Y IU2o
                      >>
                      >>>>>>>>Thank s for help so far.
                      >>
                      >>>>>>>>Runni ng Access 2003, SP2
                      >>
                      >>>>>>>>But still struggling to get it to work.
                      >>
                      >>>>>>>>I've added the following into the report under On Open Event
                      >>
                      >>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                      >>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                      >>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                      >>
                      >>>>>>>>When I try running the report it comes up with an error against the
                      >>>>>>>>first line of the code.
                      >>
                      >>>>>>>I don't use macros. I checked the Macro builder and there's no OpenArgs
                      >>>>>>>capabili ty with them. I suppose you could use RunCode and in a code
                      >>>>>>>module put the OpenReport lines in the sub.
                      >>
                      >>>>>>>Did you change "YourReportName " to the name of your report?
                      >>
                      >>>>>>>>Shoul d this code be in the report or Form for the OpenArgs to be used.
                      >>
                      >>>>>>>Usuall y I call reports from a form. I might have a command button
                      >>>>>>>CommandR eport with a caption of "Report". In the OnClick event I would
                      >>>>>>>have those 3 lines. I would not have them in the Report's module.
                      >>
                      >>>>>>>>Also see my reply direct to your email.
                      >>
                      >>>>>>>I don't think it made it. Sald may mix with oil and vinegar but there's
                      >>>>>>>not such email address as far as I know.
                      >>
                      >>>>>>>Remember , I created a text box in the Report header band. I have
                      >>>>>> =NZ([Reports]![Report1].[OpenArgs],"0")
                      >>>>>>>as the Control source (under data tab of property sheet). You need to
                      >>>>>>>change Report1 to your report's name.
                      >>
                      >>>>>>>In the footer band I put another textbox at the bottom to print the message.
                      >>>>>>=IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
                      >>>>>>>You need to change Text1 to the name of the Textbox in the Report header.
                      >>
                      >>>>>>>>Thank s in advance -
                      >>
                      >>>>>>>Here's another thing you could do. Forget the first textbox...put the
                      >>>>>>>second text box at the footer. Now open the code module for the report
                      >>>>>>>and put this code into it.
                      >>
                      >>>>>>>Privat e Function GetCopyText() As String
                      >>>>>> 'if no argument passed default to "File". Press F1
                      >>>>>> 'on the word NZ for help if necessary.
                      >>>>>> Select Case NZ(Me.OpenArgs, 3)
                      >>>>>> Case 1
                      >>>>>> GetCopyText = "Customer"
                      >>>>>> Case 2
                      >>>>>> GetCopyText = "Accounts"
                      >>>>>> Case Else
                      >>>>>> GetCopyText = "File"
                      >>>>>> End Select
                      >>>>>> GetCopyText = GetCopyText & " Copy - Print "
                      >>>>>> GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
                      >>>>>>>End Function
                      >>
                      >>>>>>>Now in the ControlSource for the textbox in the report's page footer enter
                      >>>>>> =GetCopyText()
                      >>>>>>>This will call the function GetCopyText and print the result in the footer.
                      >>
                      >>>>>>>Either way works.
                      >>
                      >>>>>>>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1-Hidequotedtext -
                      >>
                      >>>>>>>- Show quoted text -
                      >>
                      >>>>>>Thanks for your help.
                      >>
                      >>>>>>I moved the the lines of code to the button on the Form and it
                      >>>>>>generat es the printouts.
                      >>
                      >>>>>>The query I've generated prompts the user to enter an invoice number,
                      >>>>>>to gather the information for the report.
                      >>>>>>When I print invoice, the reports are generated but I have to enter
                      >>>>>>the invoice number three times.
                      >>
                      >>>>>>Do you know how I can reduce this to entering only once ?
                      >>
                      >>>>>>Thanks again.
                      >>
                      >>>>>The easist way I know to do that is to create a TextBox on the form and
                      >>>>>allow the user to enter an invoice number. Then when you print the
                      >>>>>report by pressing the Report command button do something like
                      >>>> Private Sub CommandReport_C lick()
                      >>>> If Not IsNull(Me.Invoi ceNumber) Then
                      >>>> ...print report(s)
                      >>>> Else
                      >>>> msgbox "Please supply an invoice number."
                      >>>> Me.InvoiceNumbe r.SetFocus
                      >>>> Endif
                      >>>> End Sub
                      >>
                      >>>>>Now lets say that this form is called Form1. Open up the query in
                      >>>>>design mode and under the InvoiceNumber column in the Criteria row enter
                      >>>> Forms!Form1!Inv oiceNumber
                      >>>>>You'd want to change Form1 to whatever formname you have.
                      >>
                      >>>>>Now what happens if you print all three reports and the first one prints
                      >>>>>OK and then jams on the 2nd or 3rd report. You could create an Option
                      >>>>>group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
                      >>>>>Default value (under Data tab) is 0, name of option group is Frame1.
                      >>>>>Then when you print your code could be something like
                      >>>> Private Sub CommandReport_C lick()
                      >>>> Dim intFor As Integer
                      >>>> If Not IsNull(Me.Invoi ceNumber) Then
                      >>>> If Me.Frame1 <0 then
                      >>>> Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
                      >>>> Else
                      >>>> For intFor = 1 to 3
                      >>>> Docmd.OpenRepor t "YourReport",,, ,,intFor
                      >>>> Next
                      >>>> Else
                      >>>> msgbox "Please supply an invoice number."
                      >>>> Me.InvoiceNumbe r.SetFocus
                      >>>> Endif
                      >>>> End Sub
                      >>
                      >>>>>Destinatio n Unknownhttp://www.youtube.com/watch?v=uitCCcL AtGw-Hidequoted text -
                      >>
                      >>>>>- Show quoted text -
                      >>
                      >>>>Thank you for your help.
                      >>
                      >>>>It has been gratelly appreciated.- Hide quoted text -
                      >>
                      >>>>- Show quoted text -
                      >>
                      >>>Hi me again,
                      >>
                      >>>With the code you gave me thought problem sorted.
                      >>
                      >>>For some reason when I put
                      >>
                      >>>Forms!Form1! InvoiceNumber
                      >>
                      >>>in the criteria, an error occurred invalid syntax regarding the
                      >>>expression .
                      >>
                      >>>I changed it to the following based upon the help files but I get a
                      >>>request for a parameter value.
                      >>
                      >>>[Forms]![Finance Invoice Form]![Internal ID]
                      >>
                      >>>Any Ideas ?
                      >>
                      >>Let's see, select all records from these tables where the invoice number
                      >>is equal to an invoice number in...a closed form. I wonder what that
                      >>invoice number is?
                      >>
                      >>Are you calling this report form a form's code? Or are you calling it
                      >>from the report's recordsource?
                      >>
                      >>I create form's to call reports. I can then provide options, any that I
                      >>like, and giving users choices to filter the report, direct the output,
                      >>exit without printing, etc.- Hide quoted text -
                      >>
                      >>- Show quoted text -
                      >
                      >
                      I have a Subform called invoicing, which is then linked to a header
                      Form.
                      >
                      I placed your code in the subform Invoicing and without entering the
                      code into the query, the report prints out all invoices it can find,
                      and three times as per the above code.
                      >
                      it would be fine if I wanted to print all invoices, but when I only
                      want to select the current invoice record using the code in the
                      criteria, I get a data mismatch when I try to print.
                      >
                      I can email a copy of the Database for you to look at and point me in
                      the right direction, if it help resolve the problem.
                      >
                      Thanks
                      OK. You're in a subform. I have no idea what the invoice number
                      textbox is called. I'll use InvNum. Substitute InvNum below with
                      whatever you are using.

                      First thing. If you pass a number, you don't surround it with anything.
                      If the invoice number is not a numeric field (look at your table) then
                      you surround it in quotes.

                      Now...I'll assume you are sitting on the record WITH the invoice number.

                      First, open up the query and remove any references to the
                      Forms!Form!InvN um or [Enter InvNum] in the criteria row.

                      OK. We have a clean invoice query in the report and whereever.
                      Now...when you print a report you have various arguments you can pass.
                      So why not pass the InvNum you are sitting on in the subform?
                      *if the field InvNum is a number
                      Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,1
                      Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,2
                      Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,3

                      *if the field InvNum is a text field
                      Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",1
                      Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",2
                      Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",3

                      Small Potatoes

                      Comment

                      • Studiotyphoon

                        #12
                        Re: Print a report 3 times with 3 different fields visible

                        On Apr 23, 9:13 pm, Salad <o...@vinegar.c omwrote:
                        Studiotyphoon wrote:
                        On Apr 22, 11:35 pm, Salad <o...@vinegar.c omwrote:
                        >
                        >Studiotyphoo n wrote:
                        >
                        >>On Apr 22, 11:07 am, Studiotyphoon <a...@pidesign. co.ukwrote:
                        >
                        >>>On Apr 21, 10:49 pm, Salad <o...@vinegar.c omwrote:
                        >
                        >>>>Studiotypho on wrote:
                        >
                        >>>>>On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
                        >
                        >>>>>>Studiotyp hoon wrote:
                        >
                        >>>>>>>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
                        >
                        >>>>>>>>Studiot yphoon wrote:
                        >
                        >>>>>>>>>Hi,
                        >
                        >>>>>>>>>I have report which I need to print 3 times, but would like to have
                        >>>>>>>>>the following headings
                        >
                        >>>>>>>>>Custom er Copy - Print 1
                        >>>>>>>>>Accoun ts Copy - Print 2
                        >>>>>>>>>File Copy -Print 3
                        >
                        >>>>>>>>>I created a macro to print the report three times, but do not know how
                        >>>>>>>>>I can display each text field for each print.
                        >
                        >>>>>>>>>Can anybody point me in the right direction.
                        >
                        >>>>>>>>What version of Access are you using?  There is an OpenArgs parameter
                        >>>>>>>>you can pass to the report in A2003.  Ex:
                        >>>>>>>    DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                        >>>>>>>    DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                        >>>>>>>    DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                        >
                        >>>>>>>>The 1,2,3 is the argument.  I created a report called Report1.  I
                        >>>>>>>>creat ed 2 text boxes; Text1 and Text2.  I put Text1 in the report's
                        >>>>>>>>heade r, visible = False.  I put Text2 in the Report footer.
                        >
                        >>>>>>>>In Text1 I entered, for the ControlSource in the Data tab,
                        >>>>>>>    =NZ([Reports]![Report1].[OpenArgs],"0")
                        >>>>>>>>as Report1 is the name of the report.
                        >
                        >>>>>>>>In Text2 I entered
                        >>>>>>>    =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"        
                        >>>>>>>>in the control source.
                        >
                        >>>>>>>>Now when I run the report, depending on the argument passed, it prints
                        >>>>>>>>the value I want.
                        >
                        >>>>>>>>Firebal lshttp://www.youtube.com/watch?v=uzkNI4Y IU2o
                        >
                        >>>>>>>Thanks for help so far.
                        >
                        >>>>>>>Runnin g Access 2003, SP2
                        >
                        >>>>>>>But still struggling to get it to work.
                        >
                        >>>>>>>I've added the following into the report under On Open Event
                        >
                        >>>>>>>    DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                        >>>>>>>    DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                        >>>>>>>    DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                        >
                        >>>>>>>When I try running the report it comes up with an error against the
                        >>>>>>>first line of the code.
                        >
                        >>>>>>I don't use macros.  I checked the Macro builder and there's no OpenArgs
                        >>>>>>capabilit y with them.  I suppose you could use RunCode and in a code
                        >>>>>>module put the OpenReport lines in the sub.
                        >
                        >>>>>>Did you change "YourReportName " to the name of your report?
                        >
                        >>>>>>>Should this code be in the report or Form for the OpenArgs to be used.
                        >
                        >>>>>>Usually I call reports from a form.  I might have a command button
                        >>>>>>CommandRe port with a caption of "Report".  In the OnClick event Iwould
                        >>>>>>have those 3 lines.  I would not have them in the Report's module..
                        >
                        >>>>>>>Also see my reply direct to your email.
                        >
                        >>>>>>I don't think it made it.  Sald may mix with oil and vinegar but there's
                        >>>>>>not such email address as far as I know.
                        >
                        >>>>>>Remembe r, I created a text box in the Report header band.  I have
                        >>>>>     =NZ([Reports]![Report1].[OpenArgs],"0")
                        >>>>>>as the Control source (under data tab of property sheet).  You need to
                        >>>>>>change Report1 to your report's name.
                        >
                        >>>>>>In the footer band I put another textbox at the bottom to print themessage.
                        >>>>>=IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
                        >>>>>>You need to change Text1 to the name of the Textbox in the Report header.
                        >
                        >>>>>>>Thanks in advance -
                        >
                        >>>>>>Here's another thing you could do.  Forget the first textbox...put the
                        >>>>>>second text box at the footer.  Now open the code module for the report
                        >>>>>>and put this code into it.
                        >
                        >>>>>>Private Function GetCopyText() As String
                        >>>>>     'if no argument passed default to "File".  Press F1
                        >>>>>     'on the word NZ for help if necessary.
                        >>>>>     Select Case NZ(Me.OpenArgs, 3)
                        >>>>>     Case 1
                        >>>>>             GetCopyText = "Customer"
                        >>>>>     Case 2
                        >>>>>             GetCopyText = "Accounts"
                        >>>>>     Case Else
                        >>>>>             GetCopyText = "File"
                        >>>>>     End Select
                        >>>>>     GetCopyText = GetCopyText & " Copy - Print "
                        >>>>>     GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
                        >>>>>>End Function
                        >
                        >>>>>>Now in the ControlSource for the textbox in the report's page footer enter
                        >>>>>     =GetCopyText()
                        >>>>>>This will call the function GetCopyText and print the result in thefooter.
                        >
                        >>>>>>Either way works.
                        >
                        >>>>>>Feels Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1-Hidequotedtext-
                        >
                        >>>>>>- Show quoted text -
                        >
                        >>>>>Thanks for your help.
                        >
                        >>>>>I moved the the lines of code to the button on the Form and it
                        >>>>>generate s the printouts.
                        >
                        >>>>>The query I've generated prompts the user to enter an invoice number,
                        >>>>>to gather the information for the report.
                        >>>>>When I print invoice, the reports are generated but I have to enter
                        >>>>>the invoice number three times.
                        >
                        >>>>>Do you know how I can reduce this to entering only once ?
                        >
                        >>>>>Thanks again.
                        >
                        >>>>The easist way I know to do that is to create a TextBox on the form and
                        >>>>allow the user to enter an invoice number.  Then when you print the
                        >>>>report by pressing the Report command button do something like
                        >>> Private Sub CommandReport_C lick()
                        >>>      If Not IsNull(Me.Invoi ceNumber) Then
                        >>>              ...print report(s)
                        >>>      Else
                        >>>              msgbox "Please supply an invoice number."
                        >>>              Me.InvoiceNumbe r.SetFocus
                        >>>      Endif
                        >>> End Sub
                        >
                        >>>>Now lets say that this form is called Form1.  Open up the query in
                        >>>>design mode and under the InvoiceNumber column in the Criteria row enter
                        >>>      Forms!Form1!Inv oiceNumber
                        >>>>You'd want to change Form1 to whatever formname you have.
                        >
                        >>>>Now what happens if you print all three reports and the first one prints
                        >>>>OK and then jams on the 2nd or 3rd report.  You could create an Option
                        >>>>group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
                        >>>>Default value (under Data tab) is 0, name of option group is Frame1.
                        >>>>Then when you print your code could be something like
                        >>> Private Sub CommandReport_C lick()
                        >>>      Dim intFor As Integer
                        >>>      If Not IsNull(Me.Invoi ceNumber) Then
                        >>>              If Me.Frame1 <0 then
                        >>>                      Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
                        >>>              Else
                        >>>                For intFor = 1 to 3
                        >>>                      Docmd.OpenRepor t "YourReport",,, ,,intFor
                        >>>                Next                         
                        >>>      Else
                        >>>              msgbox "Please supply an invoice number."
                        >>>              Me.InvoiceNumbe r.SetFocus
                        >>>      Endif
                        >>> End Sub
                        >
                        >>>>Destinati on Unknownhttp://www.youtube.com/watch?v=uitCCcL AtGw-Hidequotedtext -
                        >
                        >>>>- Show quoted text -
                        >
                        >>>Thank you for your help.
                        >
                        >>>It has been gratelly appreciated.- Hide quoted text -
                        >
                        >>>- Show quoted text -
                        >
                        >>Hi me again,
                        >
                        >>With the code you gave me thought problem sorted.
                        >
                        >>For some reason when I put
                        >
                        >>Forms!Form1!I nvoiceNumber
                        >
                        >>in the criteria, an error occurred  invalid syntax regarding the
                        >>expression.
                        >
                        >>I changed it to the following based upon the help files but I get a
                        >>request for a parameter value.
                        >
                        >>[Forms]![Finance Invoice Form]![Internal ID]
                        >
                        >>Any Ideas ?
                        >
                        >Let's see, select all records from these tables where the invoice number
                        >is equal to an invoice number in...a closed form.  I wonder what that
                        >invoice number is?
                        >
                        >Are you calling this report form a form's code?  Or are you calling it
                        >from the report's recordsource?
                        >
                        >I create form's to call reports.  I can then provide options, any thatI
                        >like, and giving users choices to filter the report, direct the output,
                        >exit without printing, etc.- Hide quoted text -
                        >
                        >- Show quoted text -
                        >
                        I have a Subform called invoicing, which is then linked to a header
                        Form.
                        >
                        I placed your code in the subform Invoicing and without entering the
                        code into the query, the report prints out all invoices it can find,
                        and three times as per the above code.
                        >
                        it would be fine if I wanted to print all invoices, but when I only
                        want to select the current invoice record using the code in the
                        criteria, I get a data mismatch when I try to print.
                        >
                        I can email a copy of the Database for you to look at and point me in
                        the right direction, if it help resolve the problem.
                        >
                        Thanks
                        >
                        OK.  You're in a subform.  I have no idea what the invoice number
                        textbox is called.  I'll use InvNum.  Substitute InvNum below with
                        whatever you are using.
                        >
                        First thing.  If you pass a number, you don't surround it with anything.
                          If the invoice number is not a numeric field (look at your table) then
                        you surround it in quotes.
                        >
                        Now...I'll assume you are sitting on the record WITH the invoice number.
                        >
                        First, open up the query and remove any references to the
                        Forms!Form!InvN um or [Enter InvNum] in the criteria row.
                        >
                        OK.  We have a clean invoice query in the report and whereever.
                        Now...when you print a report you have various arguments you can pass.
                        So why not pass the InvNum you are sitting on in the subform?
                           *if the field InvNum is a number
                           Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,1
                           Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,2
                           Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,3
                        >
                           *if the field InvNum is a text field
                           Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",1
                           Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",2
                           Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",3
                        >
                        Small Potatoes ...
                        >
                        read more »- Hide quoted text -
                        >
                        - Show quoted text -
                        Glad to know there are people like yourself willing to help.

                        Thanks, It worked a treat.

                        Comment

                        • Salad

                          #13
                          Re: Print a report 3 times with 3 different fields visible

                          Studiotyphoon wrote:
                          On Apr 23, 9:13 pm, Salad <o...@vinegar.c omwrote:
                          >
                          >>Studiotypho on wrote:
                          >>
                          >>>On Apr 22, 11:35 pm, Salad <o...@vinegar.c omwrote:
                          >>
                          >>>>Studiotypho on wrote:
                          >>
                          >>>>>On Apr 22, 11:07 am, Studiotyphoon <a...@pidesign. co.ukwrote:
                          >>
                          >>>>>>On Apr 21, 10:49 pm, Salad <o...@vinegar.c omwrote:
                          >>
                          >>>>>>>Studioty phoon wrote:
                          >>
                          >>>>>>>>On Apr 21, 4:29 pm, Salad <o...@vinegar.c omwrote:
                          >>
                          >>>>>>>>>Studio typhoon wrote:
                          >>
                          >>>>>>>>>>On Apr 19, 8:51 pm, Salad <o...@vinegar.c omwrote:
                          >>
                          >>>>>>>>>>>Stud iotyphoon wrote:
                          >>
                          >>>>>>>>>>>>H i,
                          >>
                          >>>>>>>>>>>>I have report which I need to print 3 times, but would like to have
                          >>>>>>>>>>>>t he following headings
                          >>
                          >>>>>>>>>>>>Cus tomer Copy - Print 1
                          >>>>>>>>>>>>Acc ounts Copy - Print 2
                          >>>>>>>>>>>>Fil e Copy -Print 3
                          >>
                          >>>>>>>>>>>>I created a macro to print the report three times, but do not know how
                          >>>>>>>>>>>>I can display each text field for each print.
                          >>
                          >>>>>>>>>>>>C an anybody point me in the right direction.
                          >>
                          >>>>>>>>>>>Wh at version of Access are you using? There is an OpenArgs parameter
                          >>>>>>>>>>>yo u can pass to the report in A2003. Ex:
                          >>>>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                          >>>>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                          >>>>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                          >>
                          >>>>>>>>>>>Th e 1,2,3 is the argument. I created a report called Report1. I
                          >>>>>>>>>>>crea ted 2 text boxes; Text1 and Text2. I put Text1 in the report's
                          >>>>>>>>>>>head er, visible = False. I put Text2 in the Report footer.
                          >>
                          >>>>>>>>>>>In Text1 I entered, for the ControlSource in the Data tab,
                          >>>>>>>>>> =NZ([Reports]![Report1].[OpenArgs],"0")
                          >>>>>>>>>>>as Report1 is the name of the report.
                          >>
                          >>>>>>>>>>>In Text2 I entered
                          >>>>>>>>>> =IIf([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File")) & " Copy"
                          >>>>>>>>>>>in the control source.
                          >>
                          >>>>>>>>>>>No w when I run the report, depending on the argument passed, it prints
                          >>>>>>>>>>>th e value I want.
                          >>
                          >>>>>>>>>>>Fire ballshttp://www.youtube.com/watch?v=uzkNI4Y IU2o
                          >>
                          >>>>>>>>>>Thank s for help so far.
                          >>
                          >>>>>>>>>>Runni ng Access 2003, SP2
                          >>
                          >>>>>>>>>>But still struggling to get it to work.
                          >>
                          >>>>>>>>>>I'v e added the following into the report under On Open Event
                          >>
                          >>>>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "1"
                          >>>>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "2"
                          >>>>>>>>>> DoCmd.OpenRepor t "YourReportName ", , , , , "3"
                          >>
                          >>>>>>>>>>Whe n I try running the report it comes up with an error against the
                          >>>>>>>>>>fir st line of the code.
                          >>
                          >>>>>>>>>I don't use macros. I checked the Macro builder and there's no OpenArgs
                          >>>>>>>>>capabi lity with them. I suppose you could use RunCode and in a code
                          >>>>>>>>>modu le put the OpenReport lines in the sub.
                          >>
                          >>>>>>>>>Did you change "YourReportName " to the name of your report?
                          >>
                          >>>>>>>>>>Shoul d this code be in the report or Form for the OpenArgs to be used.
                          >>
                          >>>>>>>>>Usuall y I call reports from a form. I might have a command button
                          >>>>>>>>>Comman dReport with a caption of "Report". In the OnClick event I would
                          >>>>>>>>>have those 3 lines. I would not have them in the Report's module.
                          >>
                          >>>>>>>>>>Als o see my reply direct to your email.
                          >>
                          >>>>>>>>>I don't think it made it. Sald may mix with oil and vinegar but there's
                          >>>>>>>>>not such email address as far as I know.
                          >>
                          >>>>>>>>>Rememb er, I created a text box in the Report header band. I have
                          >>>>>>>> =NZ([Reports]![Report1].[OpenArgs],"0")
                          >>>>>>>>>as the Control source (under data tab of property sheet). You need to
                          >>>>>>>>>chan ge Report1 to your report's name.
                          >>
                          >>>>>>>>>In the footer band I put another textbox at the bottom to print the message.
                          >>>>>>>>>=IIf ([Text1]="1","Customer" ,IIf([Text1]="2","Account", "File"))
                          >>>>>>>>>You need to change Text1 to the name of the Textbox in the Report header.
                          >>
                          >>>>>>>>>>Thank s in advance -
                          >>
                          >>>>>>>>>Here 's another thing you could do. Forget the first textbox...put the
                          >>>>>>>>>seco nd text box at the footer. Now open the code module for the report
                          >>>>>>>>>and put this code into it.
                          >>
                          >>>>>>>>>Privat e Function GetCopyText() As String
                          >>>>>>>> 'if no argument passed default to "File". Press F1
                          >>>>>>>> 'on the word NZ for help if necessary.
                          >>>>>>>> Select Case NZ(Me.OpenArgs, 3)
                          >>>>>>>> Case 1
                          >>>>>>>> GetCopyText = "Customer"
                          >>>>>>>> Case 2
                          >>>>>>>> GetCopyText = "Accounts"
                          >>>>>>>> Case Else
                          >>>>>>>> GetCopyText = "File"
                          >>>>>>>> End Select
                          >>>>>>>> GetCopyText = GetCopyText & " Copy - Print "
                          >>>>>>>> GetCopyText = GetCopyText & NZ(Me.OpenArgs, 3)
                          >>>>>>>>>End Function
                          >>
                          >>>>>>>>>Now in the ControlSource for the textbox in the report's page footer enter
                          >>>>>>>> =GetCopyText()
                          >>>>>>>>>This will call the function GetCopyText and print the result in the footer.
                          >>
                          >>>>>>>>>Eith er way works.
                          >>
                          >>>>>>>>>Feel s Goodhttp://www.youtube.com/watch?v=xA4lPE4 MI6A&NR=1-Hidequotedtext-
                          >>
                          >>>>>>>>>- Show quoted text -
                          >>
                          >>>>>>>>Thank s for your help.
                          >>
                          >>>>>>>>I moved the the lines of code to the button on the Form and it
                          >>>>>>>>generat es the printouts.
                          >>
                          >>>>>>>>The query I've generated prompts the user to enter an invoice number,
                          >>>>>>>>to gather the information for the report.
                          >>>>>>>>When I print invoice, the reports are generated but I have to enter
                          >>>>>>>>the invoice number three times.
                          >>
                          >>>>>>>>Do you know how I can reduce this to entering only once ?
                          >>
                          >>>>>>>>Thank s again.
                          >>
                          >>>>>>>The easist way I know to do that is to create a TextBox on the form and
                          >>>>>>>allow the user to enter an invoice number. Then when you print the
                          >>>>>>>report by pressing the Report command button do something like
                          >>>>>>Private Sub CommandReport_C lick()
                          >>>>>> If Not IsNull(Me.Invoi ceNumber) Then
                          >>>>>> ...print report(s)
                          >>>>>> Else
                          >>>>>> msgbox "Please supply an invoice number."
                          >>>>>> Me.InvoiceNumbe r.SetFocus
                          >>>>>> Endif
                          >>>>>>End Sub
                          >>
                          >>>>>>>Now lets say that this form is called Form1. Open up the query in
                          >>>>>>>design mode and under the InvoiceNumber column in the Criteria row enter
                          >>>>>> Forms!Form1!Inv oiceNumber
                          >>>>>>>You'd want to change Form1 to whatever formname you have.
                          >>
                          >>>>>>>Now what happens if you print all three reports and the first one prints
                          >>>>>>>OK and then jams on the 2nd or 3rd report. You could create an Option
                          >>>>>>>group with 4 options; 0 = All, 1 = Cust, 2 = Accounts, 3 = File.
                          >>>>>>>Defaul t value (under Data tab) is 0, name of option group is Frame1.
                          >>>>>>>Then when you print your code could be something like
                          >>>>>>Private Sub CommandReport_C lick()
                          >>>>>> Dim intFor As Integer
                          >>>>>> If Not IsNull(Me.Invoi ceNumber) Then
                          >>>>>> If Me.Frame1 <0 then
                          >>>>>> Docmd.OpenRepor t "YourReport",,, ,,Me.Frame1
                          >>>>>> Else
                          >>>>>> For intFor = 1 to 3
                          >>>>>> Docmd.OpenRepor t "YourReport",,, ,,intFor
                          >>>>>> Next
                          >>>>>> Else
                          >>>>>> msgbox "Please supply an invoice number."
                          >>>>>> Me.InvoiceNumbe r.SetFocus
                          >>>>>> Endif
                          >>>>>>End Sub
                          >>
                          >>>>>>>Destinat ion Unknownhttp://www.youtube.com/watch?v=uitCCcL AtGw-Hidequotedtext -
                          >>
                          >>>>>>>- Show quoted text -
                          >>
                          >>>>>>Thank you for your help.
                          >>
                          >>>>>>It has been gratelly appreciated.- Hide quoted text -
                          >>
                          >>>>>>- Show quoted text -
                          >>
                          >>>>>Hi me again,
                          >>
                          >>>>>With the code you gave me thought problem sorted.
                          >>
                          >>>>>For some reason when I put
                          >>
                          >>>>>Forms!Form 1!InvoiceNumber
                          >>
                          >>>>>in the criteria, an error occurred invalid syntax regarding the
                          >>>>>expression .
                          >>
                          >>>>>I changed it to the following based upon the help files but I get a
                          >>>>>request for a parameter value.
                          >>
                          >>>>>[Forms]![Finance Invoice Form]![Internal ID]
                          >>
                          >>>>>Any Ideas ?
                          >>
                          >>>>Let's see, select all records from these tables where the invoice number
                          >>>>is equal to an invoice number in...a closed form. I wonder what that
                          >>>>invoice number is?
                          >>
                          >>>>Are you calling this report form a form's code? Or are you calling it
                          >>>
                          >>>>from the report's recordsource?
                          >>
                          >>>>I create form's to call reports. I can then provide options, any that I
                          >>>>like, and giving users choices to filter the report, direct the output,
                          >>>>exit without printing, etc.- Hide quoted text -
                          >>
                          >>>>- Show quoted text -
                          >>
                          >>>I have a Subform called invoicing, which is then linked to a header
                          >>>Form.
                          >>
                          >>>I placed your code in the subform Invoicing and without entering the
                          >>>code into the query, the report prints out all invoices it can find,
                          >>>and three times as per the above code.
                          >>
                          >>>it would be fine if I wanted to print all invoices, but when I only
                          >>>want to select the current invoice record using the code in the
                          >>>criteria, I get a data mismatch when I try to print.
                          >>
                          >>>I can email a copy of the Database for you to look at and point me in
                          >>>the right direction, if it help resolve the problem.
                          >>
                          >>>Thanks
                          >>
                          >>OK. You're in a subform. I have no idea what the invoice number
                          >>textbox is called. I'll use InvNum. Substitute InvNum below with
                          >>whatever you are using.
                          >>
                          >>First thing. If you pass a number, you don't surround it with anything.
                          > If the invoice number is not a numeric field (look at your table) then
                          >>you surround it in quotes.
                          >>
                          >>Now...I'll assume you are sitting on the record WITH the invoice number.
                          >>
                          >>First, open up the query and remove any references to the
                          >>Forms!Form!In vNum or [Enter InvNum] in the criteria row.
                          >>
                          >>OK. We have a clean invoice query in the report and whereever.
                          >>Now...when you print a report you have various arguments you can pass.
                          >>So why not pass the InvNum you are sitting on in the subform?
                          > *if the field InvNum is a number
                          > Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,1
                          > Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,2
                          > Docmd.OpenRepor t "YourReportName ",,,"InvNum = " & Me.InvNum,3
                          >>
                          > *if the field InvNum is a text field
                          > Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",1
                          > Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",2
                          > Docmd.OpenRepor t "YourReportName ",,,"InvNum = '" & Me.InvNum & "'",3
                          >>
                          >>Small Potatoes ...
                          >>
                          >>read more »- Hide quoted text -
                          >>
                          >>- Show quoted text -
                          >
                          >
                          Glad to know there are people like yourself willing to help.
                          >
                          Thanks, It worked a treat.
                          You got it working? Fantastic!

                          Hip Hip Hurray :)

                          Comment

                          Working...