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

Set a error trap in Crystal

I have data used in a crystal report and there is a specific field Serial number that sometimes gets corupt and causes the report to stall when the following formula gets implimented.
Replace(Picture(Split({parc_txt.'SerialNo#'}, '=')[2], '20xx/xx/xx xx:xx'),"'","") and below is the data field example :

'5478=1101210316'
'621=11011118316'
'529'
'5478=1101210316'

So when the second part of the serial number and the equal sign is missing the proccess stops with an error.

I was thinking counting the characters and using an if statement which if true will function else skip.
0
John-S Pretorius
Asked:
John-S Pretorius
  • 6
  • 3
1 Solution
 
mlmccCommented:
That is the only way to do it.  You can't trap errors in formulas

Something like

If InStr({parc_txt.'SerialNo#'}, '=') > 0 then
    Replace(Picture(Split({parc_txt.'SerialNo#'}, '=')[2], '20xx/xx/xx xx:xx'),"'","")
Else
   ""

mlmcc
0
 
John-S PretoriusTechnical Service Manager, Mid-AtlanticAuthor Commented:
As soon as I introduce the formula this Else "" function somehow fails on the the next instruction when it's read.
0
 
John-S PretoriusTechnical Service Manager, Mid-AtlanticAuthor Commented:
After this formula is passed I introduce cdatetime on the result and it seems that it doesn't like the if ""
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
John-S PretoriusTechnical Service Manager, Mid-AtlanticAuthor Commented:
OK This is what I did (adding some formula to your edition), again it's most probably not the best or most efficient in any Crystal terms but I'm learning :

If InStr({parc_txt.'SerialNo#'}, '=') < 0 then  
    Replace(Picture(Split({parc_txt.'SerialNo#'}, '=')[2], '20xx/xx/xx xx:xx'),"'","") else
Replace(Picture(Split('9999=1103061206', '=')[2], '20xx/xx/xx xx:xx'),"'","")

then in Group selection I did the following :
length ({parc_txt.'SerialNo#'}) >5
0
 
John-S PretoriusTechnical Service Manager, Mid-AtlanticAuthor Commented:
Added some aditional workaround but your guidance was key.
0
 
mlmccCommented:
FYI - InStr cannot be < 0 as it is 0 when the search string isn't found.  The Len is what solved it for you.

mlmcc
0
 
John-S PretoriusTechnical Service Manager, Mid-AtlanticAuthor Commented:
Thank you for pointing that out. I do see this now, it seems by just using the Length statement in Grouping filters it out before the formula can evaluate it.

very good, you have been extremely helpfull - Thank You.
0
 
John-S PretoriusTechnical Service Manager, Mid-AtlanticAuthor Commented:
Curios mlmcc how do we make readers aware of this since I awarded the solution to you but in my case it may be easier just to filter it out ? or is it just my original question that was not clear enough. What is your thoughts.
0
 
mlmccCommented:
I think it will be useful as is but you could click the REQUEST ATTENTION link in the question body and explain what you want done.  The moderators can accept your comment and award the points to my comment as an assisted answer.

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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