Home General

Seach for specific text in String field

Hey there,

I was just trying to find a specific text in a string field the database provides.

For example, I have a field that contains this text: "fnwefuhaCXRsafhi1235". Now I want to build a procedure that searches this field for a specific string, say "CXR". This text can be positioned at any point in the string field.

In SQL I'd just use LIKE and the specific string with wildcards. Is there something like that in Report Builder?
Couldn't find anything on the matter via search.


Thanks in advance.

Comments

  • Hi Lars,

    When using the DADE Query Designer, it is possible to define the "Like" search operator using the search tab. This can then be linked to a report parameter value and used with the AutoSearch feature if needed.

    image


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Hi Nico,

    thanks for your reply. This isn't really what I need - probably because my question was too vague.

    I can't use the search function as this limits the data the report can use. Otherwise the "Like" option in your screenshould would be my choice as well.


    So let my rephrase what I need to do.

    My database contains a String field and I must check it for multiple Strings it can hold:
    * If the string "AAA" is somewhere in it, the element DBText1 needs to be visible and DBText2 invisible.
    * If the string "BBB" is somewhere in it, the element DBText2 needs to be visible and DBText1 invisible.
    * If none of the above applies, both DBText1 and 2 need to be invisible but DBText3 must be visible and contain a custom text.

    That's why I can't use the search function of the query (probably). I can't seem to find a way to search for strings within a field when building a calculation in the Calc tab.
  • lbulbu
    edited February 2021
    Well, so I think I got it. For anyone looking for something like this, I basically used the following code (it's a little simplified):


    var
    iPos: Integer;
    strSearch: String;

    begin
    Text := DBRichText2.PlainText;

    repeat
    strSearch := 'AAA';
    iPos := Pos(strSearch, Text);
    if (iPos > 0) then
    begin
    DBText1.Visible := true;
    DBText2.Visible := false;
    end;
    until iPos = 0;

    repeat
    strSearch := 'BBB';
    iPos := Pos(strSearch, Text);
    if (iPos > 0) then
    begin
    DBText1.Visible := false;
    DBText2.Visible := true;
    end;
    until iPos = 0;

    end;
  • Excellent! Glad you got it working.


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.