Link to home
Start Free TrialLog in
Avatar of InvisibleMan
InvisibleMan

asked on

Crystal Report Run Time Error 20515 - In Formula??

Hello all.  I have a crystal report on some citrex boxes.  I keep getting an error:
Run Time error '20515'

Error in Formula <cDateYeaEndDate>.
'cdate({rptAddressReport.YearEndDate})
'
The remaining text does not appear to be part of the formula.

I can open it in Crystal Designer on the same machine and it runs fine.  It is within the VB app when it hits the code to open the report it gets the error everytime.  But in designer it opens perfect on the same exact machine.

Here is the VB Code:
CrystalReport1.ReportFileName = App.Path & "\Reports\rptAddressReports.rpt"
CrystalReport1.Connect = cn(GCONN)
CrystalReport1.WindowState = crptMaximized
CrystalReport1.Action = 1
Avatar of Mike McCracken
Mike McCracken

I assume the cn(GCONN)is correct.

The reports are in the specified path?    Are you opening the same report in the designer that the VB app is opening?  I tend to do my development in one directory but run from another so occasionally I get that problem of forgetting to copy the modified report to the application directory then wonder why the two are different.

I don't see anything wrong with the code unless AppPath has a \ at the end. I can never remember whether it does or not.

mlmcc
Avatar of InvisibleMan

ASKER

All the above is correct.  The only crystal report I am having trouble with is this one with the formula for date in it.  All other work fine
I assume the cn(GCONN)is correct (Yes, I will double check that though but yes)

The reports are in the specified path?   (Yes)

 Are you opening the same report in the designer that the VB app is opening?  (Yes)

All the pathing must be right because the error is coming from the report.  I assume it might be a DLL issue on the server.  Maybe the "Uxxx".dlls like U2bar.dll etc.
Some of the reports on these machine are both Crystal 7.0 and some Crystal 8.5.  The one I am having the issue with is 8.5 I beleive though and when I open it on the same server in designed which is 8.5 it opens.
DOes your application have the correct CR dll selected.  Look under(i think)
Insert -->  Reference
Scroll down to the CR refences.  They should say something about CR 8.5  if not you need to upgrade them

mlmcc
By the way I would recommend you upgrade all your reports to the same version if at all possible.  I relize some users may have older vesions and you can't do that but trying to maintain report on multiple versions of CR will become a nightmare.

mlcc
How do I pass this formula through my VB code?  Maybe that will solve the issue?

The formula name is: @cDateYeaEndDate
The formula is:
cdate({rptAddressReport.YearEndDate})
What do you mean "How do I pass this formula through my VB code?  "

Are you wanting to pass a value to the report from VB?

What is the exact formula?

mlmcc
What do you mean "How do I pass this formula through my VB code?  "

Are you wanting to pass a value to the report from VB?

What is the exact formula?

mlmcc
InvisibleMan, I believe this is what you are looking for:


'Text1.text -- The user entered a date in the format "MM/DD/YY", but this
'is basically the format that you set for the parameter in Crystal...

'Set Date Formula
sParm1 = "Date(" & Format(Text1.Text, "YYYY") & ", " & Format(Text1.Text, "MM") & ", " & Format(Text1.Text, "DD") & ")"
crRPT.Formulas(0) = "Startdate= '" & sParm1  & "'"

'Set Date Prameter
sParm1 = "@StartDate"
crRPT.ParameterFields(0) = sParm1 & ";" & Text1.Text & ";TRUE"


HTH
-Robg69
Sorry, you don't need the single quotes on the following line:
crRPT.Formulas(0) = "Startdate= " & sParm1  

I was cutting and pasting from different places. :D

-Robg69
Ok all here is where I am at.

Update on issue,

I have a Crystal Report that has a formula called:
@cDateYeaEndDate

The formula is:
CDate({rptAddressReport.YearEndDate})

I am getting the above mentioned error 20515

I tried changing this to CDateTime also Date and still no dice.  The report opens fine in the Crystal Report Designer on the same machine and it runs perfect.  In the VB runtime exe it gets this error.  What do I need to do to troubleshoot this.  There are many other reports so I am afraid to update DLL's on that machine.  But why would the designer work and not the runtime call to the report.  The report is definatly trying to open because it is getting the error.
I noticed that all the Conversion functions do not work.  I can however use the string functions such as Trim, Uppercase, etc.  I am looking at the UFL libraries.  Something is not on the machine.  I reinstalled both Crystal 7.0 and 8.5 on the machine still no luck.  On my machine it works perfect though.  I even installed VB 6 on the machine still same issue.
Ok, may be a few things. It sounds like the date may be null or not a valid date? Or in the database table, the field is not a date, datetime, etc (hence the cdate?) Try something like this:
 
if isnull({rptAddressReport.YearEndDate}) then
    "Null"
else if trim({rptAddressReport.YearEndDate}) = '' then
    "Blank"
else
    totext(cdate({rptAddressReport.YearEndDate}))

This should show you at least what data you are getting and shouldn't get an error (unless the data is not valid).

Also, are you using the date for some calculation or just showing it. If you are showing it, then you don't have to do the cdate on it (but I'm sure you know that). I  don't think it's a dll problem, b/c I've gotten that error a million times and have always been able to fix it in code -- but I've been wrong b4.

Anyway, HTH,

-Robg69
It is not just this data.  I tried this on example databases as well.  Any of the conversion functions I am getting this error.  I am guessing there is a problem with the DLLs on this machine.  I need to figure out what DLLs I should be focusing on that handle the conversion functions for date etc.  The CDate does not work at all in runtime on every new report I tested on that machine.
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial