Skip to main content

Search

Search

DB Field, Search total number of Characters (or will fit in Specified space) if not replace with Text

Comments

2 comments

  • Avatar
    Peter Thane

    I think you would need to use VB to be honest. 

    This should do the job, I hope, although as the data is coming from a data base you would need to set the VB to an Event Controlled Script routine, set to OnNewRecord:

    (My test label is not linked to a database but I have added a Named Data Source, "TheData" instead.)

    To Replace the full contents then you could use a VB routine like this:

    Value = Format.NamedSubStrings("TheData").Value

    Value1 = Len(Format.NamedSubStrings("TheData").Value)

    If Value1 > 15 then
    Value = "Too Long Matey"
    else
    Value = Value

    end if

    Note: This is set to replace a string that is 15 characters long. To connect the commands to your Database field for the 1st two lines type in the Value = or the Value1 = Len(  and then from the column on the right double click on your database field name to add that to the script. For the Len command make sure to add a ) closing bracket afterwards.

    To restrict the length and then append a comment then you could use this code

    Value = Format.NamedSubStrings("TheData").Value

    Value1 = Len(Format.NamedSubStrings("TheData").Value)

    If Value1 > 15 then
    Value = Left(Value,15) & " the rest is history"
    else
    Value = Value

    end if

     

     

     

    0
  • Avatar
    MICHAEL GOODWIN

    You Sir, are worth more money thankyou!

    0

Please sign in to leave a comment.