Print Page | Close Window

Error in Formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=23033
Printed Date: 01 May 2024 at 5:35am


Topic: Error in Formula
Posted By: Lord Yorkshire
Subject: Error in Formula
Date Posted: 07 Mar 2023 at 6:20am
I have a report that runs most of the time, but if i have a blank field it errors.

I am trying to pull a number out of a string but if there is no number, i get a non numeric error message.

How do i introduce a bit that says if there is no number after the “:” just put 1

tonumber(right({SfReport.Ta18},(len({SfReport.Ta18})- (Instr({SfReport.Ta18}, ":") ))))

The data looks like this

Sheet Size : 1200
Or
Sheet Size :

1st one is fine, 2nd one is where i get the error.



Replies:
Posted By: Valert16
Date Posted: 08 Mar 2023 at 12:00am
Use this code (Crystal syntax):

If IsNumeric(Trim((split({SfReport.Ta18}, ":")[2]))) Then
    ToNumber(split({SfReport.Ta18}, ":")[2])
Else
    1


Posted By: Lord Yorkshire
Date Posted: 08 Mar 2023 at 1:27am
Thank you, that worked and now the report gives me the information exactly as i wanted.




Print Page | Close Window