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.

    <font face="Courier New"> <font color="#ff0000"> Lable46.Visible=True
    </font><font face="Courier New"> Select Case Field1.DataValue
       Case "B77", B"93"
          Field4. <font color="#ff0000"> DataValue</font> = Field4.DataValue + txtorder_amount.DataValue
       Case "C1"
       Case "C30"
    End Select</font>
  • 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 <img src="/emoticons/emotion-1.gif" alt="Smile" /> Since VB Script is more primitive than VB I hade had CAST the DataValue to double instead. Before I could present it...

    <font color="#0000ff" size="2"> Sub</font> <font size="2"> OnBeforePrint</font>

    <font color="#0000ff" size="2"> If</font> <font size="2"> rpt.Field1.DataValue = "B77"</font> <font color="#0000ff" size="2"> Then</font>

    <font size="2"> rpt.Label46.Visible =</font> <font color="#0000ff" size="2"> True</font>

    <font size="2"> rpt.Field4.Visible =</font> <font color="#0000ff" size="2"> True</font>

    <font size="2"> rpt.Field4.DataValue = 0</font>

    <font color="#ff0000"> rpt.Field4.DataValue = CDbl(rpt.Field4.DataValue) + CDbl(rpt.txtorder_amount.DataValue)</font>

    <font color="#0000ff" size="2"> End</font> <font color="#0000ff" size="2"> If
    End Sub

    <font color="#0000ff" size="2">  </font>

Need extra support?

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

Learn More

Forum Channels