Solved

Set a error trap in Crystal

Posted on 2011-03-15
9
388 Views
Last Modified: 2012-05-11
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
Comment
Question by:John-S Pretorius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 125 total points
ID: 35143554
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
 

Author Comment

by:John-S Pretorius
ID: 35143613
As soon as I introduce the formula this Else "" function somehow fails on the the next instruction when it's read.
0
 

Author Comment

by:John-S Pretorius
ID: 35143694
After this formula is passed I introduce cdatetime on the result and it seems that it doesn't like the if ""
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

Author Comment

by:John-S Pretorius
ID: 35143975
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
 

Author Closing Comment

by:John-S Pretorius
ID: 35143979
Added some aditional workaround but your guidance was key.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 35144101
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
 

Author Comment

by:John-S Pretorius
ID: 35146996
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
 

Author Comment

by:John-S Pretorius
ID: 35147011
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 35150169
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question