• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 697
  • Last Modified:

String Search in Crystal Report

I have comment field in my report that is delimited by commas and spaces;
ex:
Type=D, create user= test user1, modified user = test1, Apply to inventory
Captial#123456
SDE#78910

I'm trying to search the string and ONLY pull out the information that starts with SDE.

I"ve tried using the formula: split({L_HPCR.OBJECT},",")[4], but if the SDE# isn't right after the third comma, it won't display.

Anyone have any suggestions.

Thank you
0
metalteck
Asked:
metalteck
  • 3
  • 2
1 Solution
 
mlmccCommented:
Try this

Local NumberVar SDE_Loc;
SDE_Loc := InStr({L_HPCR.OBJECT},"SDE");
Mid({L_HPCR.OBJECT},SDE_Loc)

mlmcc
0
 
metalteckAuthor Commented:
At first it worked, but then I got an error saying" Start Position is less than 1 or not an integer".

Ideas?
0
 
mlmccCommented:
Apparently you have strings without the SDE or NULL

Local NumberVar SDE_Loc;
If IsNull({L_HPCR.OBJECT}) then
   "No String"
Else
(
    SDE_Loc := InStr({L_HPCR.OBJECT},"SDE");
    If SDE_Loc > 0 then
        Mid({L_HPCR.OBJECT},SDE_Loc)
    Else
        "No SDE"
);

mlmcc

mlmcc
0
 
metalteckAuthor Commented:
Thats perfect. One last question, what happens if SDE is in lowercase?
How would I capture all versions of the word sde?
0
 
mlmccCommented:
SDE_Loc := InStr(UCase({L_HPCR.OBJECT}),"SDE");

mlmcc
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now