Problem making controls in detail section the same height

Posted by: gemse64 on 4 August 2017, 3:23 pm EST

  • Posted 4 August 2017, 3:23 pm EST

    Hello,

    I use the following code to make the controls the same heigt within the detail section.

    Sub OnBeforePrint

    Dim ctrl
    Dim sec
    Dim localheight
    Dim Y
    Set sec = rpt.Sections("Detail")
    localheight = 0
    'Get maximum height of fields
    Y = sec.Controls.Count
    For Y = 0 To sec.Controls.Count-1
    If TypeOf sec.Controls(Y) is Field Then
    If sec.Controls(Y).Height > localheight Then
    'Check the height of each element
    localheight = sec.Controls(Y).Height
    End If
    End If
    Next
    Set all fields to maximum height
    If TypeOf sec.Controls(Y) is Field Then
    If Y=0 Then
    sec.Controls(Y).Height = localheight
    End If
    Next

    End Sub

    However I get a sysntax error because of the following line:

    If TypeOf sec.Controls(Y) is Field Then


    I also tried the following which I got out of the refernce guide but it still get the same error:
    If TypeOf sec.Controls(Y) is DDActiveReports2.Field Then

    What do I need to specify instead?

    I appreciate your help very much

    Thanks in advance for any clues!!

  • Replied 4 August 2017, 3:23 pm EST

    gemse64,

    Please use the following code (this is called on Form Load event) to get the desired results:

    Private Sub Form_Load()
    Dim rpt As New ActiveReport1
    Dim ctl As Field
    Dim sec
    Dim localheight
    Dim Y
    Set sec = rpt.Sections("Detail")
    localheight = 0
    'Get maximum height of fields
    Y = sec.Controls.Count
    For Y = 0 To sec.Controls.Count - 1
    If TypeOf sec.Controls(Y) Is Field Then
    If sec.Controls(Y).Height > localheight Then
    'Check the height of each element
    localheight = sec.Controls(Y).Height
    End If
    End If
    Next
    For Each ctl In sec.Controls
    If TypeName(ctl) = "Field" Then
    ctl.Height = localheight
    End If
    Next
    rpt.Show
    End Sub


    Let me know if this helps.

    Regards,
    Sankalp
  • Replied 4 August 2017, 3:23 pm EST


    The syntax error 5800 for the line

    If TypeOf sec.Controls(Y) Is Field Then

    unfortunately remains.

    Best regards

    Monika
  • Replied 4 August 2017, 3:23 pm EST

    Monika,

    Unfortunately I am unable to replicate this issue. The code which I provided to you works perfectly at my end. Please check the attached screenshots. The first one shows how the controls look in the designer and the second one shows the output on the viewer, where all the controls have been set to the same height.

    In addition to this, I have also attached the sample project which implements this functionality. Please take a look and let me know if you have any doubts.

    Regards,
    Sankalp




    2014/08/FieldHeight_ARCOM.zip
  • Replied 4 August 2017, 3:23 pm EST

    Hello Sankalp,

    thanks for the answer. No I sure don't have any doubts.
    Our software uses the Active Reports' ActiveX Viewer control from which I use the script editor which gives me the option to include code for the "on format", the "before print" and the the "after print" event. Running the script produces the syntax error mentioned earlier.
    The rest of the syntax works fine but it doesn't like the TypeOf function.

    Either the behaviour is different in the constellation where I use Active Reports or my last hope is that I need a new build if one exists.
    My current version is 2.3.0.1261

    Could it be that a more recent build exists?

    Best regards
    Monika
  • Replied 4 August 2017, 3:23 pm EST

    Monika,

    Please try using the latest build which can be downloaded from here:
    download.componentone.com/pub/ar2stdeval2501322.zip

    This is an evaluation installer and will not prompt you for your license credentials upon installation. Let me know if you have any doubts.

    Regards,
    Sankalp
Need extra support?

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

Learn More

Forum Channels