Code in Designers section or in the section and VB scipt??

Posted by: henrikg-dd on 4 August 2017, 2:35 pm EST

  • Posted 4 August 2017, 2:35 pm EST

    Hi all
    I have a problem regarding executing code in the VB developement environment respective in "runtime mode" just calling the rpt, outside the development enviroment.

    The code below works fine as long as executing in developement environment and just push the usual run (F5) BUT outside the dev enviroment it does not work???
    Input please, am I on the wrong track? I don't get it?
    Are there rules where to put the code?

    Private Sub Detail_BeforePrint()
    If Field1.DataValue = "B77" Then
    Field4 = Field4.DataValue + txtorder_amount.DataValue
    End If
    If Field1.DataValue = "B93" Then
    Field4 = Field4.DataValue + txtorder_amount.DataValue
    End If
    If Field1.DataValue = "C1" Then
    Field4.Visible = False
    End If
    If Field1.DataValue = "C30" Then
    Label46.Visible = False
    Field4.Visible = False
    End If
    End Sub
  • Replied 4 August 2017, 2:35 pm EST

    How are you deploying your report? Building it into your program's EXE? As a custom DLL? A RPX file?

    If one of the first two try putting your code in the appropriate Format section, in this case the Detail_Format. If the last option is true you will need to use scripting.

    Also you could use a Case structure instead of your series of If statements. You should probably send your expression result back to the DataValue since that is what you are using for the calculation, especially if you have any formating declared in the OutputFormat for Field4. Lastly I noticed that you have no way of turning Visibility back on, a good idea of a previous row had a 'C' value that turned it off.

    Lable46.Visible=True
    Field4.Visible=True

    Select Case Field1.DataValue
       Case "B77", B"93"
          Field4. DataValue = Field4.DataValue + txtorder_amount.DataValue
       Case "C1"
          Field4.Visible=Fase
       Case "C30"
          Lable46.Visible=False
          Field4.Visible=Fase
    End Select
  • Replied 4 August 2017, 2:35 pm EST

    Hi Wsmith,
    I deploy it as an rpx, and therefore I need to put the code in the detail section as a VB script. I just solved it Smile Since VB Script is more primitive than VB I hade had CAST the DataValue to double instead. Before I could present it...

    Sub OnBeforePrint

    If rpt.Field1.DataValue = "B77" Then

    rpt.Label46.Visible = True

    rpt.Field4.Visible = True

    rpt.Field4.DataValue = 0

    rpt.Field4.DataValue = CDbl(rpt.Field4.DataValue) + CDbl(rpt.txtorder_amount.DataValue)

    End If
    End Sub


     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels