Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    multiple copies of a report (AccessXP)

    We need to print a report to be sent to clients but need to print multiple copies of the report if the client address has any CC: names. In the query that populates the report, I have a "Qty" field that counts the number of CC: names. What I need to know is how to use this number to print the appropriate number of copies. I adapted some info found KB article 299024 but need to know how to implement it in the "Onformat" event of the report.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: multiple copies of a report (AccessXP)

    In one print run, will you be printing a report for one client only, or for a series of clients, with a different number of copies to be printed for each client?

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: multiple copies of a report (AccessXP)

    We would like to make one print run but we want to print multiple copies of the report for those clients who have multiple CC: names. Example - Client ABC has no CC: names therefore only one copy but client DEF has 2 CC: and needs three copies of the their report.
    I have this code in the page header section but it does not repeat when needed.

    Private Sub PageHeaderSection_Print(Cancel As Integer, PrintCount As Integer)
    Dim intCopyCount As Integer 'qty count from query
    Dim I As Integer 'counter
    'qty 0 means one copy to be printed
    'qty greater than 0 means qty value to be printed.

    intCopyCount = Me.Qty
    If intCopyCount > 0 Then
    For I = 1 To intCopyCount + 1
    Me.NextRecord = False
    Next I
    Else
    Me.NextRecord = True
    End If
    End Sub

    The report looks like this:
    ======================
    Page header - contains nothing Height = 0
    NameHeader - contains the client name, address, date and cc: lines
    ABC Company
    123 Anystreet
    Anytown, ST, 12345-5678

    Date

    cc: =IIf(IsNull([CC]),"","cc: " & [CC1] & Chr(13) & Chr(10) & IIf(IsNull([CC 2]),""," " & [CC2]))

    Some standard text. " Attached please find your monthly reports....blah blah"

    Client Number Header - two sub reports separated by a PageBreak control
    SubReport A - Active accounts
    SubReport B - Closed Accounts

    Detail section - contains nothing - Height = 0

    Page footer Section- contains nothing - Height = 0
    Hope this helps.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: multiple copies of a report (AccessXP)

    Can't you setup a loop in the calling form for the number of reports required like:

    For IntNo =1 to CCcnt
    DoCmd.OpenReport .......
    Next IntNo

    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: multiple copies of a report (AccessXP)

    1a. Declare intCopyCount in the declaration section of the report module, not in one of the event procedures. It is a variable used throughout the report module.
    1b. Remove the code you have from the Page Header section - it would interfere with what follows.

    2. In the OnPrint event of the Name header section, reset intCopyCount to 0:

    Private Sub NameHeader_Print(Cancel As Integer, PrintCount As Integer)
    intCopyCount = 0
    End Sub

    3. In the OnPrint event of the Client Number header section, increase intCopyCount and defer going to the next record until Qty is reached:

    Private Sub ClientNumberHeader(Cancel As Integer, PrintCount As Integer)
    If intCopyCount < Me.Qty Then
    NextRecord = False
    intCopyCount = intCopyCount + 1
    End If
    End Sub

  6. #6
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: multiple copies of a report (AccessXP)

    Pat,
    The quantity (intCopyCount) is calculated in the query that populates the report. Would I be able to set the loop in the form not knowing the value of intCopyCount first?

    However, the form has a multiselect listbox where the client(s) are selected. If no clients are selected, all reports are printed. I could attach a quantity to each client in the listbox by adjusting the query in the rowsource property, I suppose. Or do you think there is an easier way?
    Best regards,

  7. #7
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    Virginia, USA
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: multiple copies of a report (AccessXP)

    Hans,
    Thanks. This works fine for the subreports and prints the correct quantities. The only problem now is that we need the Name Section to print before each of the copies. For example, when we come to a customer with 2 CC names, we get:

    Section Header with Company Name, address, City, St, Zip, CCs
    Copy one of subreport 1
    Copy one of subreport2
    Copy two of subreport 1
    copy two of subreport 2
    copy three of subreport 1
    copy three of subreport 2

    So, we are going to explore adding another section heading. Any suggestions?
    thanks,

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: multiple copies of a report (AccessXP)

    Haven't tested this, but try adding another Name header section before the one you now have. Set its height to 0 and move the code from the OnPrint event of the original Name header section to the OnPrint event of the new one

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: multiple copies of a report (AccessXP)

    Yes that's the way I would do it, this way you don't have to do anything extra in the report, all you are doing is a loop to determine how many times you are going to print it with a certain criteria based upon the ListBox.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •