WordWrap at non letter or number?

Posted by: neal007 on 4 August 2017, 3:19 pm EST

  • Posted 4 August 2017, 3:19 pm EST

    Hello,
    <br />
    <br />I have a field in a simple report which holds a list of airport identifiers I call "Route of Flight". For example:
    <br />
    <br />RIC-DEN-LAX-DFW-JFK-RIC
    <br />
    <br />The problem is that when wordwrap occurs it wraps on any character and I need it to wrap at a hyphen.
    <br />
    <br />So I get:
    <br />
    <br />RIC-DEN-L
    <br />AX
    <br />
    <br />But I want:
    <br />
    <br />RIC-DEN-
    <br />LAX
    <br />
    <br />Is there a way to implement this?
    <br />
    <br />Thank you.
  • Replied 4 August 2017, 3:19 pm EST

    You can measure the field's value in the section's Format event and add custom logic for word wrapping:
    <br />
    <br />Private Sub Detail_Format()
    <br /> Dim val As String, w, h As Variant
    <br /> val = Field1.Text
    <br /> Canvas.MeasureText val, w, h
    <br />
    <br /> If w > Field1.Width Then
    <br /> ' Custom word-wrap logic modifying value of the val variable
    <br /> End If
    <br />
    <br /> Field1.Text = val
    <br />End Sub
    <br />
Need extra support?

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

Learn More

Forum Channels