Link to home
Start Free TrialLog in
Avatar of NCSO
NCSO

asked on

Print Multiple Pages using the PrintDocument Class in vb.net

I have attached the code that I am using; I know that up to (7) "Items" can fit onto a single page but I can not figure out how to make any other items print on subsequent pages.  

Your assistance is greatly appreciated
Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click
        'PrintDocument1.PrinterSettings.Copies = 1
        'PrintDocument1.Print()

        PrintPreviewDialog1.Width = FormWindowState.Maximized
        PrintPreviewDialog1.Document = PrintDocument1
        PrintPreviewDialog1.ShowDialog()

    End Sub


    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

        Dim pFont = New Font("Arial", 8.5, FontStyle.Bold)
        Dim pFont2 = New Font("Arial", 9, FontStyle.Regular)
        Dim pFont2Un = New Font("Arial", 9, FontStyle.Underline)
        Dim pFont3 = New Font("Arial", 6, FontStyle.Regular)

        'Pawn Shop Section
        e.Graphics.DrawString("FLORIDA PAWNBROKER TRANSACTION FORM", pFont, Brushes.Black, 30, 42)
        e.Graphics.DrawString("" & RadForm1.lblShopName.Text & "", pFont2, Brushes.Black, 30, 60)
        e.Graphics.DrawString("" & RadForm1.lblAddress.Text & "", pFont2, Brushes.Black, 30, 75)
        e.Graphics.DrawString("" & RadForm1.lblCityStateZip.Text & "", pFont2, Brushes.Black, 30, 90)

        'Transaction Date
        e.Graphics.DrawRectangle(Pens.Black, 365, 42, 150, 35)
        e.Graphics.FillRectangle(Brushes.LightSteelBlue, 365, 42, 150, 35)
        e.Graphics.DrawString("Transaction Date", pFont2, Brushes.Blue, 367, 43)
        e.Graphics.DrawString("" & RadForm1.txtTransactionDate.Text & "", pFont2, Brushes.Black, 367, 60)

        'Time
        e.Graphics.DrawString("Time:", pFont2, Brushes.Black, 365, 82)
        e.Graphics.DrawString("" & RadForm1.txtTransactionTime.Text & "", pFont2, Brushes.Black, 405, 82)

        'Type of Transaction
        e.Graphics.DrawString("Type of Transaction:", pFont2, Brushes.Black, 365, 102)
        If RadForm1.rbPurchaseTrade.ToggleState = 1 Then
            e.Graphics.DrawString("" & RadForm1.rbPurchaseTrade.Text & "", pFont2, Brushes.Black, 490, 102)
        End If

        If RadForm1.rbConsignment.ToggleState = 1 Then
            e.Graphics.DrawString("" & RadForm1.rbConsignment.Text & "", pFont2, Brushes.Black, 490, 102)
        End If

        If RadForm1.rbPawn.ToggleState = 1 Then
            e.Graphics.DrawString("" & RadForm1.rbPawn.Text & "", pFont2, Brushes.Black, 490, 102)
        End If

        'Control Number
        e.Graphics.DrawString("CONTROL #", pFont, Brushes.Black, 562, 42)
        e.Graphics.DrawString("" & RadForm1.txtControlNumber.Text & "", pFont2, Brushes.Black, 672, 42)

        'Department Number
        e.Graphics.DrawString("DEPT #", pFont, Brushes.Black, 562, 62)
        e.Graphics.DrawString("" & RadForm1.txtDepartmentNumber.Text & "", pFont2, Brushes.Black, 672, 62)

        'Maturity Date
        e.Graphics.DrawString("MATURITY DATE:", pFont, Brushes.Black, 562, 82)
        e.Graphics.DrawString("" & RadForm1.txtMaturityDate.Text & "", pFont2, Brushes.Black, 672, 82)

        'Pledger / Seller Section
        e.Graphics.DrawString("Pledger / Seller", pFont2, Brushes.Black, 32, 132)
        e.Graphics.DrawRectangle(Pens.Black, 30, 130, 95, 20)
        e.Graphics.DrawRectangle(Pens.Black, 30, 150, 750, 110)
        e.Graphics.DrawString("Name (Last), (First), (Middle)", pFont3, Brushes.Black, 32, 152)
        e.Graphics.DrawString("" & RadForm1.txtLastName.Text & ", " & RadForm1.txtFirstName.Text & ", " & RadForm1.txtMiddleName.Text & "", pFont2, Brushes.Black, 32, 162)
        e.Graphics.DrawLine(Pens.Black, 30, 177, 780, 177) ' Horizontal Line

        e.Graphics.DrawString("RESIDENTIAL ADDRESS (Street, Apt No., City, State & Zip", pFont3, Brushes.Black, 32, 180)
        e.Graphics.DrawString("" & RadForm1.txtAddress.Text & " " & RadForm1.txtStreetName.Text & " , " & RadForm1.txtAptNumber.Text & " " & RadForm1.txtCity.Text & ", " & RadForm1.txtState.Text & "  " & RadForm1.txtZip.Text & "", pFont2, Brushes.Black, 32, 190)
        e.Graphics.DrawLine(Pens.Black, 30, 205, 780, 205) ' Horizontal Line

        e.Graphics.DrawString("PLACE OF EMPLOYMENT", pFont3, Brushes.Black, 32, 208)
        e.Graphics.DrawString("" & RadForm1.txtEmployer.Text & "", pFont2, Brushes.Black, 32, 218)
        e.Graphics.DrawLine(Pens.Black, 30, 233, 780, 233) ' Horizontal Line

        e.Graphics.DrawString("D.L.# / OFFICIAL PHOTO ID #", pFont3, Brushes.Black, 32, 236)
        e.Graphics.DrawString("" & RadForm1.txtID.Text & "", pFont2, Brushes.Black, 32, 246)

        e.Graphics.DrawLine(Pens.Black, 365, 150, 365, 233) ' Vertical Line
        e.Graphics.DrawString("DATE OF BIRTH", pFont3, Brushes.Black, 367, 152)
        e.Graphics.DrawString("" & RadForm1.txtDOB.Text & "", pFont2, Brushes.Black, 367, 162)

        e.Graphics.DrawLine(Pens.Black, 445, 150, 445, 177) ' Vertical Line
        e.Graphics.DrawString("HOME PHONE (Area Code & Number)", pFont3, Brushes.Black, 367, 180)
        e.Graphics.DrawString("" & RadForm1.txtHomePhone.Text & "", pFont2, Brushes.Black, 367, 190)

        e.Graphics.DrawString("BUSINESS PHONE (Area Code & Number)", pFont3, Brushes.Black, 367, 208)
        e.Graphics.DrawString("" & RadForm1.txtWorkPhone.Text & "", pFont2, Brushes.Black, 367, 218)

        e.Graphics.DrawLine(Pens.Black, 525, 150, 525, 177) ' Vertical Line
        e.Graphics.DrawString("SEX (M/F)", pFont3, Brushes.Black, 447, 152)
        e.Graphics.DrawString("" & RadForm1.txtSex.Text & "", pFont2, Brushes.Black, 447, 162)

        e.Graphics.DrawString("RACE", pFont3, Brushes.Black, 527, 152)
        e.Graphics.DrawString("" & RadForm1.txtRace.Text & "", pFont2, Brushes.Black, 527, 162)

        e.Graphics.DrawLine(Pens.Black, 170, 233, 170, 260) ' Vertical Line
        e.Graphics.DrawString("TYPE", pFont3, Brushes.Black, 172, 235)
        e.Graphics.DrawString("" & RadForm1.txtIDType.Text & "", pFont2, Brushes.Black, 172, 245)

        e.Graphics.DrawLine(Pens.Black, 240, 233, 240, 260) ' Vertical Line
        e.Graphics.DrawString("AGENCY / STATE", pFont3, Brushes.Black, 242, 235)
        e.Graphics.DrawString("" & RadForm1.txtAgencyState.Text & "", pFont2, Brushes.Black, 242, 245)

        e.Graphics.DrawLine(Pens.Black, 320, 233, 320, 260) ' Vertical Line
        e.Graphics.DrawString("HEIGHT", pFont3, Brushes.Black, 322, 235)
        e.Graphics.DrawString("" & RadForm1.txtHeight.Text & "", pFont2, Brushes.Black, 322, 245)

        e.Graphics.DrawLine(Pens.Black, 400, 233, 400, 260) ' Vertical Line
        e.Graphics.DrawString("WEIGHT", pFont3, Brushes.Black, 402, 235)
        e.Graphics.DrawString("" & RadForm1.txtWeight.Text & "", pFont2, Brushes.Black, 402, 245)

        e.Graphics.DrawLine(Pens.Black, 480, 233, 480, 260) ' Vertical Line
        e.Graphics.DrawString("EYES", pFont3, Brushes.Black, 482, 235)
        e.Graphics.DrawString("" & RadForm1.txtEyes.Text & "", pFont2, Brushes.Black, 482, 245)

        e.Graphics.DrawLine(Pens.Black, 540, 233, 540, 260) ' Vertical Line
        e.Graphics.DrawString("HAIR", pFont3, Brushes.Black, 542, 235)
        e.Graphics.DrawString("" & RadForm1.txtHair.Text & "", pFont2, Brushes.Black, 542, 245)

        e.Graphics.DrawLine(Pens.Black, 600, 233, 600, 260) ' Vertical Line
        e.Graphics.DrawString("IDENTIFYING MARKS", pFont3, Brushes.Black, 602, 235)
        e.Graphics.DrawString("" & RadForm1.txtIDMarks.Text & "", pFont2, Brushes.Black, 602, 245)

        Dim itemNum As Integer
        Dim Y As Integer
        Y = 265
        Try
            For a As Integer = 0 To RadForm2.DG1.Rows.Count - 1
                itemNum = a
                Dim LineHeight As Integer = 28


                e.Graphics.DrawString("ITEM " & "" & a + 1 & "", pFont2, Brushes.Black, 32, Y)

                'Draws Left Vertical Line
                e.Graphics.DrawLine(Pens.Black, 30, Y + 13, 30, Y + 100) 'Serial Number
                e.Graphics.DrawLine(Pens.Black, 220, Y + 13, 220, Y + 42) 'Owner Applied Number
                e.Graphics.DrawLine(Pens.Black, 340, Y + 13, 340, Y + 42) 'Item Type
                e.Graphics.DrawLine(Pens.Black, 460, Y + 13, 460, Y + 42) 'Brand
                e.Graphics.DrawLine(Pens.Black, 600, Y + 13, 600, Y + 42) 'Model Number


                'Draws Top Horitontal Line
                e.Graphics.DrawLine(Pens.Black, 30, Y + 13, 780, Y + 13)

                'Draws Right Vertical Line
                e.Graphics.DrawLine(Pens.Black, 780, Y + 13, 780, Y + 100)

                'Draws Bottom Horitontal Line
                e.Graphics.DrawLine(Pens.Black, 30, Y + 100, 780, Y + 100)

                e.Graphics.DrawString("SERIAL NUMBER", pFont3, Brushes.Black, 32, Y + 16)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(4).Value.ToString & "", pFont2, Brushes.Black, 32, Y + 26)

                e.Graphics.DrawString("OWNER APPLIED NUMBER", pFont3, Brushes.Black, 222, Y + 16)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(5).Value.ToString & "", pFont2, Brushes.Black, 222, Y + 26)

                e.Graphics.DrawString("ITEM TYPE", pFont3, Brushes.Black, 342, Y + 16)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(6).Value.ToString & "", pFont2, Brushes.Black, 342, Y + 26)

                e.Graphics.DrawString("BRAND", pFont3, Brushes.Black, 462, Y + 16)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(7).Value.ToString & "", pFont2, Brushes.Black, 462, Y + 26)

                e.Graphics.DrawString("MODEL NUMBER", pFont3, Brushes.Black, 602, Y + 16)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(6).Value.ToString & "", pFont2, Brushes.Black, 602, Y + 26)

                'Draws Vertical Line
                e.Graphics.DrawLine(Pens.Black, 30, Y + 42, 780, Y + 42)
                e.Graphics.DrawLine(Pens.Black, 340, Y + 42, 340, Y + 70)
                e.Graphics.DrawLine(Pens.Black, 390, Y + 42, 390, Y + 70)
                e.Graphics.DrawLine(Pens.Black, 440, Y + 42, 440, Y + 70)
                e.Graphics.DrawLine(Pens.Black, 540, Y + 42, 540, Y + 70)
                e.Graphics.DrawLine(Pens.Black, 590, Y + 42, 590, Y + 70)
                e.Graphics.DrawLine(Pens.Black, 640, Y + 42, 640, Y + 70)

                e.Graphics.DrawString("TYPE", pFont3, Brushes.Black, 342, Y + 44)
                If RadForm2.DG1.Rows(a).Cells(9).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(9).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 340, Y + 54)
                End If

                e.Graphics.DrawString("ACTION", pFont3, Brushes.Black, 392, Y + 44)
                If RadForm2.DG1.Rows(a).Cells(10).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(10).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 392, Y + 54)
                End If

                e.Graphics.DrawString("GUAGE CALIBER", pFont3, Brushes.Black, 442, Y + 44)
                If RadForm2.DG1.Rows(a).Cells(11).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(11).Value.ToString & "", pFont2, Brushes.Black, 442, Y + 54)
                End If

                e.Graphics.DrawString("FINISH", pFont3, Brushes.Black, 542, Y + 44)
                If RadForm2.DG1.Rows(a).Cells(12).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(12).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 542, Y + 54)
                End If

                e.Graphics.DrawString("BARREL", pFont3, Brushes.Black, 592, Y + 44)
                If RadForm2.DG1.Rows(a).Cells(13).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(13).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 592, Y + 54)
                End If

                e.Graphics.DrawString("AMOUNT", pFont3, Brushes.Black, 642, Y + 44)
                If RadForm2.DG1.Rows(a).Cells(3).Value.ToString <> "" Then
                    e.Graphics.DrawString("$" & RadForm2.DG1.Rows(a).Cells(3).Value.ToString & "", pFont2, Brushes.Black, 642, Y + 54)
                End If


                e.Graphics.DrawString("DESCRIPTION", pFont3, Brushes.Black, 32, Y + 44)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(1).Value.ToString & "", pFont2, Brushes.Black, 32, Y + 55)
                'Draws Horitontal Line
                e.Graphics.DrawLine(Pens.Black, 30, Y + 70, 780, Y + 70)

                'Draws Vertical Line
                e.Graphics.DrawLine(Pens.Black, 70, Y + 70, 70, Y + 100) 'Jewelry Type
                e.Graphics.DrawLine(Pens.Black, 110, Y + 70, 110, Y + 100) ' Metal
                e.Graphics.DrawLine(Pens.Black, 150, Y + 70, 150, Y + 100) ' KT
                e.Graphics.DrawLine(Pens.Black, 190, Y + 70, 190, Y + 100) ' WT
                e.Graphics.DrawLine(Pens.Black, 230, Y + 70, 230, Y + 100) ' Gender
                e.Graphics.DrawLine(Pens.Black, 270, Y + 70, 270, Y + 100) ' Style
                e.Graphics.DrawLine(Pens.Black, 340, Y + 70, 340, Y + 100) ' Size/Length
                e.Graphics.DrawLine(Pens.Black, 380, Y + 70, 380, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 420, Y + 70, 420, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 460, Y + 70, 460, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 500, Y + 70, 500, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 540, Y + 70, 540, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 580, Y + 70, 580, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 620, Y + 70, 620, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 660, Y + 70, 660, Y + 100)
                e.Graphics.DrawLine(Pens.Black, 700, Y + 70, 700, Y + 100)

                e.Graphics.DrawString("TYPE", pFont3, Brushes.Black, 32, Y + 72)

                If RadForm2.DG1.Rows(a).Cells(15).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(15).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 32, Y + 82)
                End If

                e.Graphics.DrawString("METAL", pFont3, Brushes.Black, 72, Y + 72)
                If RadForm2.DG1.Rows(a).Cells(16).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(16).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 72, Y + 82)
                End If

                e.Graphics.DrawString("KT.", pFont3, Brushes.Black, 112, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(17).Value.ToString & "", pFont2, Brushes.Black, 112, Y + 82)

                e.Graphics.DrawString("WEIGHT", pFont3, Brushes.Black, 152, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(18).Value.ToString & "", pFont2, Brushes.Black, 152, Y + 82)

                e.Graphics.DrawString("GENDER", pFont3, Brushes.Black, 192, Y + 72)
                If RadForm2.DG1.Rows(a).Cells(19).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(19).Value.ToString.Substring(0, 1) & "", pFont2, Brushes.Black, 192, Y + 82)
                End If

                e.Graphics.DrawString("STYLE", pFont3, Brushes.Black, 232, Y + 72)
                If RadForm2.DG1.Rows(a).Cells(20).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(20).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 232, Y + 82)
                End If

                e.Graphics.DrawString("SIZE LENGTH", pFont3, Brushes.Black, 272, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(21).Value.ToString & "", pFont2, Brushes.Black, 272, Y + 82)

                e.Graphics.DrawString("# STONE", pFont3, Brushes.Black, 342, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(22).Value.ToString & "", pFont2, Brushes.Black, 342, Y + 82)

                e.Graphics.DrawString("SHAPE", pFont3, Brushes.Black, 382, Y + 72)
                If RadForm2.DG1.Rows(a).Cells(23).Value.ToString.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(23).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 382, Y + 82)
                End If

                e.Graphics.DrawString("CT", pFont3, Brushes.Black, 422, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(24).Value.ToString & "", pFont2, Brushes.Black, 422, Y + 82)

                e.Graphics.DrawString("WT", pFont3, Brushes.Black, 462, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(25).Value.ToString & "", pFont2, Brushes.Black, 462, Y + 82)

                e.Graphics.DrawString("COLOR", pFont3, Brushes.Black, 502, Y + 72)
                If RadForm2.DG1.Rows(a).Cells(26).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(26).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 502, Y + 82)
                End If

                e.Graphics.DrawString("# STONE", pFont3, Brushes.Black, 542, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(27).Value.ToString & "", pFont2, Brushes.Black, 542, Y + 82)

                e.Graphics.DrawString("SHAPE", pFont3, Brushes.Black, 582, Y + 72)
                If RadForm2.DG1.Rows(a).Cells(28).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(28).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 582, Y + 82)
                End If

                e.Graphics.DrawString("CT", pFont3, Brushes.Black, 622, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(29).Value.ToString & "", pFont2, Brushes.Black, 622, Y + 82)

                e.Graphics.DrawString("WT", pFont3, Brushes.Black, 662, Y + 72)
                e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(30).Value.ToString & "", pFont2, Brushes.Black, 662, Y + 82)

                e.Graphics.DrawString("COLOR", pFont3, Brushes.Black, 702, Y + 72)
                If RadForm2.DG1.Rows(a).Cells(31).Value.ToString <> "" Then
                    e.Graphics.DrawString("" & RadForm2.DG1.Rows(a).Cells(31).Value.ToString.Substring(0, 2) & "", pFont2, Brushes.Black, 702, Y + 82)
                End If




                Y = Y + 115

            Next

        Catch ex As Exception

        End Try


    End Sub

Open in new window

document.pdf
Avatar of Hawkvalley1
Hawkvalley1
Flag of United States of America image

I would use two variables (class level) one that I increment with each iteration of the items, while checking the other against the bottom margin and increasing this variable as the y axis for your drawstring position. When we reach the bottom you set the e.HasMorePages to true and exit the sub. When it fires again it will continue the iteration from that variable. Consider any parts of the form that you want to continue for each page like a title or logo.
Don't forget to dispose of those fonts. Using/End Using works great here.
Avatar of NCSO
NCSO

ASKER

I have tried the following but when it jumps to nextpage e.hasmorepages = true the count of print just counts up...

Dim ItemCount as Integer = 0
                ItemCount += 1

                If ItemCount > 6 Then
                    GoTo NextPage
                End If

NextPage:
                e.HasMorePages = True
Avatar of NCSO

ASKER

What I would like to accompish is, if there are more than (6) items on a page then duplicate the document on page 2-??? and increment the item number.  I hope this makes since; in other words, keep the header information of the original page one but start the item number 1 higher than the last one on the previous page.
ASKER CERTIFIED SOLUTION
Avatar of Hawkvalley1
Hawkvalley1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NCSO

ASKER

so if I understand you correctly, I would do the following:

'normal header code
Dim row As Integer = <some value to start with for y coord>
For i As Integer = item_index To RadForm2.DG1.Rows.Count - 1
   If row < (e.MarginBounds.Bottom - 40) Then 'change the 40 to whatever makes since that just gives me 2 lines

<HERE I place my code to write the item section>
     
   Else
      e.HasMorePages = True
      Exit Sub
   End If
item_index = i
Next
'at the end of the sub reset the variable
If Not e.HasMorePages Then  item_index = 0
Avatar of NCSO

ASKER

I have used the code provided but I am not having favorable results.  Would you mind showing me exactly where and how to place the code to get it working?  I would greatly appreciate it.
I used <i> instead of <a> for the loop variable. That should be the only change you need. The <a> variable is just referencing the row we are printing on and it will start where we left off. Your header should print just fine.
Avatar of NCSO

ASKER

I did exactly that and I added 6 or so items, when I previewed the print it continued down the first page and began at item 1 again and never showed a second page
Avatar of NCSO

ASKER

when I debug the code, it never reaches the else statement.
Avatar of NCSO

ASKER

If I debug/run through the try statement 6 times and then set the else statement as the next statement; it works.   Items 1-6 are on page one and 7-8 are on page two
Since you have a Y variable just get rid of the row variable I created and evaluate your Y variable if it less than the bottom.
Avatar of NCSO

ASKER

replacing the "row" variable with "y" did allow the else statement to fire off and create the next page.  However, on page 1 I have items 1-7, on page 2 I have 7-9; so the last one on the first page is being duplicated on the next
Avatar of NCSO

ASKER

Thanks!!!!!