INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Using if then else & instr in Crystal Reports

Using if then else & instr in Crystal Reports

(OP)
The following formula works according to Crystal's formula checker but when I use it the formula to group in Crystal the error message is: Start position is less than 1 or not an integer

if instr({table_date.balance_accrual},"Accrual","1")>0
then "Accrual Loans"
else "Other"

I will be adding more "if instr"s after the current else in case that influences the answer.

I've searched the instr posts but nothing I've found or tried seems to resolve this issue. I'm guessing it is a relatively basic syntax issue, but I can't find the issue.

RE: Using if then else & instr in Crystal Reports

Try this instead:


if Accrual" IN ({table_date.balance_accrual}
then "Accrual Loans"
else "Other"

RE: Using if then else & instr in Crystal Reports

(OP)
I appreciate the prompt response! The formula checker responded with "A string is required here" which makes sense since the field {table_date.balance_accrual} is a balance field and not a string field.

So I am checking for text in the name of a balance field - that complicates the formula I'm trying to create. Do you have other suggestions? Thanks!

RE: Using if then else & instr in Crystal Reports

Oops, my post is missing a quote which may be causing the error. Should be:

if "Accrual" IN ({table_date.balance_accrual}
then "Accrual Loans"
else "Other"

RE: Using if then else & instr in Crystal Reports

(OP)
Thanks, Charily, but I had caught the missing " and used it and got the error I mentioned above.

I also just tried:

if "Accrual" IN totext(({table_date.balance_accrual}))
then "Accrual Loans"
else "Other"

and I got no errors but all results were "Other," so while not yielding an error, it isn't finding / yielding a result of "Accrual Loans" *&^%ing syntax, lol. I'm running out of ideas...

RE: Using if then else & instr in Crystal Reports

So what does the data for {table_date.balance_accrual}) actually look like? If it is not a string, then how can you find the word Accrual in it?

RE: Using if then else & instr in Crystal Reports

(OP)
Kray, you nailed it and I realized it after the fact. I was trying to create a group off of a numeric field by recognizing the name of the field - my mistake! I'll pursue another technique using the above on a text field.

Thanks for the help!

RE: Using if then else & instr in Crystal Reports

Are you trying to do something like this:

IF {table_date.balance_accrual} > 0
then "Accrual Loans"
else "Other"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close