How to print text or an image in the header based on a control break

89 Views Asked by At

I am customizing our MICR check. We often print hundreds of checks. Some of the checks pay many remit-to's and so the remit lines don't all fit on one page so there is overflow. We need to print VOID over the check itself, which is in the HEADER on the second and subsequent pages for that check.

I wrote a visibility expression as follows:

=Iif(Globals!PageNumber > 1, False, True)

What that accomplished was hiding it on page 1 of the print job. The problem is that most pages after page 1 were new checks and shouldn't be voided. Only the second page from the same check should.
I need to do this on a control break where he check number changes. I should only print VOID when the current page has the same check number as the previous page. Since this is in the header, the check number refers to a hidden field in the body:

=reportitems!txtCalc_DspCheckNum21.value

I would compare this value to the previous check number but how do I store that previous check number and now compare the two?

I added a text box (very large letters) over the check and hid it. I then

1

There are 1 best solutions below

5
Chris Latta On

You'll probably need to set this up using custom code.

In your Report Properties-Code page, insert the following code:

Dim LastCheck As String
Dim ThisCheck As String

Function SetCheck(CheckNumber As String) AS String
Begin
    LastCheck = ThisCheck
    ThisCheck = CheckNumber
    Return ThisCheck
End

Now for your Textbox txtCalc_DspCheckNum21 give it the expression:

=Code!SetCheck(Fields!CheckNum.Value)

In your header, set the image Visiblility-Hidden expression to:

=IIF(Code.ThisCheck = Code.LastCheck, False, True)

So what we are doing is that whenever your Textbox txtCalc_DspCheckNum21 gets rendered, it remembers the previous and current check numbers. If they are different (i.e. the first page for that cheque) it hides the image and if they are the same, it shows the VOID image (i.e. subsequent pages for that cheque).

Note that this relies on txtCalc_DspCheckNum21 being rendered on every page.