I have a report that calls two subreports.
All three reports have their TableAdapters filled by using the FillBy Method and passing a parameter.
This functionality works great, however I need to populate both a table of contents as well as some text within the report with applicable page numbers.
To do so, I was generating the report and then using an AfterPrint function to obtain what those page numbers were, and regenerate the report with the updated values.
This worked when I was using just a Fill Method and then applying a Filter String, however the datasets have become too large thus forcing me to change the logic and use the FillBy Method.
I'm getting an error upon calling the CreateDocument method at the end of the AfterPrint function.
Here is the AfterPrint function. Any Ideas?
Visual BasicPrivate firstCreate As Boolean = True
Private Sub rpt_Arranged_IFPNG_AfterPrint(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.AfterPrint
If firstCreate Then
Dim instructions1, instructions2, itemization1, itemization2, agreement1, agreement2, disclaim1, disclaim2 As Integer
For Each page As Page In Me.Pages
Dim brickEnum As BrickEnumerator = page.GetEnumerator()
Do While brickEnum.MoveNext()
Dim brick As VisualBrick = TryCast(brickEnum.Current, VisualBrick)
If brick IsNot Nothing Then
Dim control As XRControl = TryCast(brick.BrickOwner, XRControl)
If control IsNot Nothing Then
If (control.Name = "PageFind1") Then
instructions1 = 1 + Me.Pages.IndexOf(page)
ElseIf (control.Name = "PageFind2") Then
itemization1 = 1 + Me.Pages.IndexOf(page)
ElseIf (control.Name = "PageFind3") Then
agreement1 = 1 + Me.Pages.IndexOf(page)
ElseIf (control.Name = "PageFind4") Then
disclaim1 = 1 + Me.Pages.IndexOf(page)
End If
End If
End If
Loop
Next page
instructions2 = itemization1 - 1
itemization2 = agreement1 - 1
agreement2 = disclaim1 - 1
disclaim2 = Me.Pages.Count
toc1.Text = "Pages " & instructions1 & " to " & instructions2
toc2.Text = "Pages " & itemization1 & " to " & itemization2
toc3.Text = "Pages " & agreement1 & " to " & agreement2
toc4.Text = "Page " & disclaim2
section12.Text = "This Agreement contains three segments that are merged with and incorporated into a single Agreement. " & _
"Those segments are contained on pages " & instructions1 & " to " & instructions2 & " of the Agreement, the " & _
"Merchandise Selected contained on pages " & itemization1 & " to " & itemization2 & " of this Agreement, the " & _
"Agreement describing the overall nature of this Agreement, " & _
"relationship of the parties, its Provisions and the Terms and Conditions upon which the Agreement is based, " & _
"contained on pages " & agreement1 & " to " & agreement2 & " of this Agreement, and the Agreement " & _
Environment.NewLine & _
"Benefit Recipients contained on page " & disclaim2 & " of this Agreement. " & _
"The contents of this Agreement as described above contains the entire agreement between the Purchaser " & _
"supersedes any and all communications, representations, undertakings, and other agreements, whether oral or written between them " & _
"relating to the subject matter of this Agreement. No further acceptance of this Agreement by the Purchaser."
firstCreate = False
CreateDocument()
End If
End Sub
Hi Richard,
I have examined your code, and it seems to be correct. I suppose that there are other things involved at your end. Would you please provide us with a compilable sample project to demonstrate the issue? This will make the situation clearer.
I am looking forward to hearing from you.