Solved

# cannot export due to error: string length is less than 0 or not  an integer

Posted on 2006-05-09
Medium Priority
678 Views
Crystal is throwing out over this formula with error in formula: string length is less than 0 or not  an integer.  The data is all stored in uppercase.  I'm testing for null.  What else can i do?

if isnull({Record.title}) or isnull({Record.GivenName}) or isnull({Record.Surname}) then
"Title, Given Name or Surname is null"
else
if left({Record.Surname}, 2) = "MC" then
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
"Mc" & lowercase(right({Record.Surname}, length({Record.Surname})-2))
& ","
else if left({Record.Surname}, 3) = "MAC" then
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
"Mac" & lowercase(right({Record.Surname}, length({Record.Surname})-3))
& ","
else if left({Record.Surname}, 2) = "O'" then
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
"O'" & uppercase(mid({Record.Title}, 3, 1)) & lowercase(right({Record.Surname}, length({Record.Surname})-3))
& ","
else
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
uppercase(left({Record.Surname}, 1)) & lowercase(right({Record.Surname}, length({Record.Surname})-1))
& ","
0
Question by:Hecatonchires

LVL 9

Expert Comment

ID: 16646337
What kind of database are you reporting from?

Is 'convert null values to default' in report options checked or not?

--
Outin
0

LVL 16

Accepted Solution

wykabryan earned 1000 total points
ID: 16647965
My guess is since you are checking for nulls in your first statement you have a field that contains blanks, which are different than nulls.  Everything in your code appears to be correct, which would point me in that direction.  I would add this to the top.

if {Record.title}= "" or  {Record.GivenName} = "" or {Record.Surname}="" or
isnull({Record.title}) or isnull({Record.GivenName}) or isnull({Record.Surname})
then "Title, Given Name or Surname is null"
0

LVL 101

Assisted Solution

mlmcc earned 1000 total points
ID: 16654972
Do you have any surnames of just MAC or titles of a single character?  If so your length({String}) - 1 or 3 will be 0.

mlmcc
0

LVL 7

Author Comment

ID: 16663896
Hmm, I didn't get the usual 'your question has been updated' emails.

Anyway, thanks for the help.  I'll split evenly between wykabryan and mlmcc, You both helped ^_^

I ended up with:
if {Record.title}= "" or  {Record.GivenName} = "" or {Record.Surname}="" or isnull({Record.title}) or isnull({Record.GivenName}) or isnull({Record.Surname}) then
"Title, Given Name or Surname is null"
else
if left({Record.Surname}, 2) = "MC" and (length({Record.Surname})- 2) > 0 then
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
"Mc" & lowercase(right({Record.Surname}, length({Record.Surname})-2))
& ","
else if left({Record.Surname}, 3) = "MAC" and (length({Record.Surname})- 3) > 0 then
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
"Mac" & lowercase(right({Record.Surname}, length({Record.Surname})-3))
& ","
else if left({Record.Surname}, 2) = "O'" and (length({Record.Surname})- 2) > 0 then
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
"O'" & uppercase(mid({Record.Title}, 3, 1)) & lowercase(right({Record.Surname}, length({Record.Surname})-3))
& ","
else
"Dear " &
uppercase(left({Record.Title}, 1)) & lowercase(right({Record.Title}, length({Record.Title})-1))
& " " &
uppercase(left({Record.Surname}, 1)) & lowercase(right({Record.Surname}, length({Record.Surname})-1))
& ","
0

LVL 101

Expert Comment

ID: 16664061

mlmcc
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
###### Suggested Courses
Course of the Month15 days, 6 hours left to enroll