Using IF to control Page Header

  • Hi. I have the following expression to control the Page Header text based on the order prefix:

    =IIF(Left(ReportItems!RefText5.Value,3)="PUR","PURCHASE ORDER","RETURN ORDER")

    I have been asked to increase the scope to include:

    REP = Reapair

    SUB = Sub Contract

    Do I need to do a nested IF? Anyone else done this?

    Many Thanks,

    Phil.

    -------------------------------------------------------------------------------------
    A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."

    Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '

    Tommy Cooper

  • Hi Philip,

    Regards to you. 🙂

    You may try this Switch statement as below;

    =Switch(Left(ReportItems!RefText5.Value,3)="PUR","PURCHASE",

    Left(ReportItems!RefText5.Value,3)="REP","Repair",

    Left(ReportItems!RefText5.Value,3)="SUB","Sub Contract")

    Thanks alot,

    Niraj

  • Thanks Niraj. When executed returns error:

    [rsMultiReportItemsInPageSectionExpression] The Value expression for the textbox ‘textbox37’ refers to more than one report item. An expression in a page header or footer can refer to only one report item.

    Thanks,

    Phil.

    -------------------------------------------------------------------------------------
    A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."

    Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '

    Tommy Cooper

  • Can anyone with me a lesson in adding custom code for such a scenario?

    Thanks,

    Phil.

    -------------------------------------------------------------------------------------
    A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."

    Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '

    Tommy Cooper

  • I was advised by a developer to use:

    Public Function getHeaderText(ByVal purchaseOrderId As String) As String

    Select Case Left(purchaseOrderId, 3)

    Case "SUB"

    getHeaderText = "SUB CONTRACT ORDER"

    Case "REP"

    getHeaderText = "REPAIR ORDER"

    Case Else

    getHeaderText = "PURCHASE ORDER"

    End Select

    End Function

    +

    In the textbox in the layout of the report, use the following expression (this will be underlined in red, but that’s normal when calling your own function)

    = Code.getHeaderText(First(ReportItems!RefText5.Value))

    Hope this helps others.

    Phil.

    -------------------------------------------------------------------------------------
    A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."

    Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '

    Tommy Cooper

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply