Crystal Report Export Problem from Visual Basic 6.0

Hi!

I am generating some weekly reports in Crystal Reports and exports it to RTF (Disk File).  I have one text file which displays min:sec.  I need to do an average on min:sec for 7 days.  For that I have created some formula's using ToNumber, ToText, etc.  If I export it from crystal report it exports fine.  But when I am trying to export through VB automation it gives me runtime error-'2147191667(8004748d): The String in non-numeric'.  

VB Code :

Set crxExportOptions = Report.ExportOptions
crxExportOptions.FormatType = crEFTExactRichText
crxExportOptions.DestinationType = crEDTDiskFile
crxExportOptions.DiskFileName = "C:\Reports\Weekly.rtf"
Report.Export False

Initially when I was not displaying the average for min:sec the above vb code was running fine.  
Anyhelp is appreciated.  Thanks,
prirajAsked:
Who is Participating?
 
SpideyModConnect With a Mentor Commented:
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0
 
mlmccCommented:
Can you open the report in Crystal and preview it?  If so can you then export it as you want?

I suspect the problem is not with VB or the exporting but with the formulas you created.

Can you provide the formulas?

mlmcc
0
 
prirajAuthor Commented:
Hi!

I can preview in crystal reports and can export it from crystal reports and it runs fine.  Only error occurs when I try to run my automation.

ToText ({@minutes}) + ToText (".") + ToText ({@seconds})

if  {@sec} < 10 then
   ToText (ToNumber (0)) + ToText (Int ({@sec}))
else
    ToText (Int ({@sec}))

Do you think there might be any problem in above formula.  Although it runs fine with no errors in crystal reports itself.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
prirajAuthor Commented:
Hi!

I can preview in crystal reports and can export it from crystal reports and it runs fine.  Only error occurs when I try to run my automation.

ToText ({@minutes}) + ToText (".") + ToText ({@seconds})

if  {@sec} < 10 then
   ToText (ToNumber (0)) + ToText (Int ({@sec}))
else
    ToText (Int ({@sec}))

Do you think there might be any problem in above formula.  Although it runs fine with no errors in crystal reports itself.
0
 
mlmccCommented:
Try
if  {@sec} < 10 then
   '0' + ToText (Int ({@sec}))
else
   ToText (Int ({@sec}))

mlmcc
0
 
prirajAuthor Commented:
Never Mind!  I got the answer.  Actually I tried quiet similar what you mentioned but that too gives me the same error when I run my automation.  I checked all my formula's and everything worked fine in crystal reports, so I if condition and checked if it's true then proceed else display 0.  I am not sure what difference it makes but now my automation run fine.  
0
 
mlmccCommented:
If we helped please award the points.  If not then submit a request in the Community Support forum to PAQ this question

mlmcc
0
 
prirajAuthor Commented:
Hi,

I found the answer by my self.  I am not an expert in VB or crystal reports but I found that VB is not able to interpret the numeric into text.  In crystal reports my mentioned command worked fine but not through automation.
ToText ({@minutes}) + ToText (".") + ToText ({@seconds}).
Eg. In crystal reports I get 25.20 and I could perform Mathematics calculation and the result comes fine but,
Through VB Automation I get error as instead of getting 25.20 results shows 25.00.20.00 and will not be able to perform any calculation.  What I did is instead of converting into text and then to Number I did some maths calculation to get the same result and it worked fine in both crystal reports and vb automation too.  

I don’t think I need to give my point to any one as I got answer from myself.  I would like to PAQ this question.

0
 
CleanupPingCommented:
Hi priraj,
This old question (QID 20553969) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
mlmccCommented:
As I suggested  

then submit a request in the Community Support forum to PAQ this question


mlmcc
0
All Courses

From novice to tech pro — start learning today.