how can i make a report detail repeat

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zfman
    New Member
    • Jan 2014
    • 4

    how can i make a report detail repeat

    i am trying to print up vouchers for prizes for a chinese auction
    some of the prizes have more than 1 winner (ie 2 people can win a certain service)
    the service and all the information needed to print the voucher is on the table once, with a field stating how many winners (in this case, 2)
    how can i get two vouchers to print, when there is only one detail record on the table?
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    change the number if copies to 2 or 3 or whatever you need.

    Comment

    • zfman
      New Member
      • Jan 2014
      • 4

      #3
      they all have different number of copies needed - most 1, some 2, some 3, one 8...

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        zfman:
        We can play 20 Questions or you can provide all of the detail in one go.

        1)press <ctrl><p> on the reprot enough times
        2)use an inputbox to get the number of copies and then set
        3)have a field in the table with the number of copies required for each object.

        You need to provide:
        Version of Access
        Code being used to call report >>READ THIS FIRST>>> Before Posting (VBA or SQL) Code
        DETAILS about what you actually need.

        Comment

        • zfman
          New Member
          • Jan 2014
          • 4

          #5
          sorry
          i don't mean to frustrate you
          i'm just a lay person
          i'm using access 2010
          there is no code - i'm just using simple tables and reports
          the table has a field "how many" which indicates how many identical vouchers need to be printed
          i was hoping there was a way to either write a query which creates a detail for each voucher (so there would be 1 detail when [how many]=1, 2 when it equals 2, etc and the report can run off of that OR if there is a way to write code in the detail section to keep printing until the number of times it's been printed reaches how many
          it would be best if i can keep count, so i can print "n/total" on the voucher.
          thanks!!!!

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            You should be able to use the NextRecord Property of the Report Object, the Detail's Print() Event, and a Looping Structure to print Vouchers a specified number of times. The idea is as follows (has not been verified):
            1. From the Print() Event of the Report's Detail Section, read the Value of the [How Many] Field to determine the Number of Copies.
            2. Create a Looping Structure with the Number of Iterations equal to this [How Many] Value.
            3. As long as [How Many] <> Loop Counter, set the Value of Me.NextRecord = False, so as not to advance to the Next Record while printing multiple Copies of the Current one (Voucher).
            4. Once [How Many] = Loop Counter, set Me.NextRecord = True and print the next Voucher.
            5. Again, this has not been tested and only exists in the 'Dark Recessess of My Mind' (LOL).

            Comment

            • zmbd
              Recognized Expert Moderator Expert
              • Mar 2012
              • 5501

              #7
              I've a slightly simpler method now that I know what you want.

              You will need VBA as ADezii states

              Switch to design view

              In the report add a group that sorts on the primary key
              In the group header add the field to this area that has the number of repeats
              Show the properties for the group header set visible to false and set can shrink to true or auto
              Now this is arbitray, you could use the group footer instead, leave the footer visible, set to page break after the footer, set the control with the repeat value visible property to no. Because you are grouping in the primary key, then EVERY record will start a new page with the details repeating... delete the report header or move to the page header if you want it on every page... the formatting is endles

              lets move on to the engine

              Show the report properties
              events tab
              OnOpen - select code if prompted - if you attempt to use macro this wont make any sense.

              At the top of your code, before anything else:
              Code:
              Option Compare Database
              Option Explicit
              '
              Dim ZNumberRepeats As Integer
              In the open event set the ZNumberRepeats = 1

              Go back to the report design
              click on the details seperator bar
              properties
              event tab
              onformat

              In the format event here you need to set the
              ZnumberRepeats = me![FieldWithRepeat InGroupHeader]
              Go back to the report design
              click on the details seperator bar
              properties
              event tab
              onprint

              Notice here that in the procedure declaration there is a "printcount "
              Test the "PrintCount " against the znumberRepeats if equal then Me.NextRecord = True if not then false.
              (yes simple if...then (^_^) )

              I've tested this, it works in ACC2010

              I've left the coding for you to write; however, if you get stuck please post back here and I'll help


              (variation on a theme provided by Allen http://allenbrowne.com/ser-12.html
              Last edited by zmbd; Jan 14 '14, 06:13 PM.

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                If you believe you may want this for a number of reports, and don't fancy getting into VBA too heavily for this, then you can create a table in your database (We'll call it [tblCount] for now.) that contains records with a single field (We'll call it [Count] for now). [tblCount] should be populated with all numbers from 1 up to the largest number you expect to use.

                Update your query(ies) now so that they include this table unjoined. Now, all you have to do is to have a form with a control where the operator can select (or you specify in code - it really doesn't matter what drives it.) a number that they want of the report to be printed. The query(ies) also include a WHERE clause that selects only those rows where [tblCount].[Count] <= the value of the control on the form.

                One benefit of this approach is that the report then supports counting of the items it's printed.

                Comment

                • ADezii
                  Recognized Expert Expert
                  • Apr 2006
                  • 8834

                  #9
                  @zmbd:
                  You will need VBA as ADZeii states
                  I think that now is the time to tell you that it is ADezii and not ADZeii (LOL).
                  Last edited by zmbd; Jan 14 '14, 06:12 PM. Reason: [Z{It's the Gremlins I tell you, the Gremlins!}]

                  Comment

                  • zmbd
                    Recognized Expert Moderator Expert
                    • Mar 2012
                    • 5501

                    #10
                    [tblCount] should be populated with all numbers from 1 up to the largest number you expect to use.
                    As I wasn't sure how many records, I went with what I thought would be the safer route.

                    This is an example if what Neopa is suggesting:

                    The title is goofy; however, the concept OP wanted was the same.

                    Comment

                    • zfman
                      New Member
                      • Jan 2014
                      • 4

                      #11
                      the idea that "You should be able to use the NextRecord Property of the Report Object, the Detail's Print() Event, and a Looping Structure to print Vouchers a specified number of times." seems to be the most straightforward and obvious way to do it, just... i don't know the first thing about writing code
                      let me rephrase - i used to know how to write code - 30 years ago - so I understand about declaring variables and looping structures... and i can probably tweak code to fit my needs, but i don't know enough about the language to get started...
                      thanks!
                      Last edited by zfman; Jan 15 '14, 02:33 PM. Reason: left out reference

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32633

                        #12
                        ZFMan
                        "this seems to be..."
                        As this is the start of your post I would expect "this" to be referring to the latest concept discussed. As that doesn't make use of code though, the rest of what you say is confusing. Perhaps you could be clearer about what you are saying.

                        Comment

                        Working...