Link to home
Start Free TrialLog in
Avatar of Amour22015
Amour22015

asked on

Crystal Reports 2008 - String Length problem

Hi and thanks,

I have this formula:
If IsNull({TEMP_PWC_Report_SP_MAIN.ownername}) Then "" Else
Left({TEMP_PWC_Report_SP_MAIN.ownername}, Instr(LTrim({TEMP_PWC_Report_SP_MAIN.ownername}), " ") -1);

I tryed:
If {TEMP_PWC_Report_SP_MAIN.ownername} <> "" Then
Left({TEMP_PWC_Report_SP_MAIN.ownername}, Instr(LTrim({TEMP_PWC_Report_SP_MAIN.ownername}), " ") -1)
Else "";

I also tryed:
If {TEMP_PWC_Report_SP_MAIN.ownername} > "" Then
Left({TEMP_PWC_Report_SP_MAIN.ownername}, Instr(LTrim({TEMP_PWC_Report_SP_MAIN.ownername}), " ") -1)
Else "";

Looking at the data I am guessing that I am getting the error when:
There is nothing (like no last name)

Example:

Smith Mike (works)
Mike (does not work)

Please help and thanks
Avatar of Amour22015
Amour22015

ASKER

Oh yes,

forgot to mention the reason for the post:

Error:
String Length is less than 0 or not an integer.


Thanks
ASKER CERTIFIED SOLUTION
Avatar of GJParker
GJParker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So I also tryed:

If {TEMP_PWC_Report_SP_MAIN.ownername} > "" Then
Left (LTRIM({TEMP_PWC_Report_SP_MAIN.ownername}), Instr(LTrim({TEMP_PWC_Report_SP_MAIN.ownername}), " ") -1)
Else "";

Same error.


Maybe the user inputted a blank before entering in the ownername?

Please help and thanks
Thant was it thanks for your help...
Avatar of Mike McCracken
DId you try the SPLIT version from above.

The issue is you need to test that the " " exists

If {TEMP_PWC_Report_SP_MAIN.ownername} > "" Then
(
    If  Instr(LTrim({TEMP_PWC_Report_SP_MAIN.ownername}), " ")  > 0 then
          Left (LTRIM({TEMP_PWC_Report_SP_MAIN.ownername}),
                     Instr(LTrim({TEMP_PWC_Report_SP_MAIN.ownername}), " ") -1)
    Else
          LTrim({TEMP_PWC_Report_SP_MAIN.ownername})
)
Else
     "";

mlmcc
mlmcc,

I tryed the SPLIT version above and it seems to work fine?

Are you saying that I could run into some problems with the SPLIT Version?

Thanks
No.  Split returns an array of values.  If there is no space in the text then the array will have 1 element which is the one his formula displays.

I was just pointing why your formula was getting the error.

mlmcc