Sign in to follow this  
Followers 0
oktoberfest2

Crystal Reports and Date Parameters

8 posts in this topic

It appears that auto it has some problems passing in a date value to a crystal reports parameter. I'm wondering if someone has found a way around this.

Here is what I have:

Thank you

Dim $i
Dim $sReportName
Dim $CRApp
Dim $CrystalReport
Dim $CRViewer1

;Set Location of Template to Open
$sReportName = "C:\Report1.rpt"

;Create Application Object instance
$CRApp = ObjCreate("CrystalRuntime.Application")
If $CRApp = 0 Then
    MsgBox(0, "Error", "Could not create CrystalRuntime Object")
    Exit
EndIf

;Create a Report Object instance
$CrystalReport = $CRApp.OpenReport($sReportName)

;Set Login Information
_SetDataSource()

If $CrystalReport = 0 Then
    MsgBox(0, "Error", "Could not open report: " & $sReportName)
    Exit
EndIf

;Create a Report Viewer Object instance
$CRViewer1 = ObjCreate("CrystalReports11.ActiveXReportViewer.1")

;#################################################
;Pass in some parameters
;#################################################
;This works fine (Passing in a String)
$CrystalReport.ParameterFields(1).AddCurrentValue ("Passing in a String")

;This too works fine (Passing in a Number)
$CrystalReport.ParameterFields(2).AddCurrentValue (100)
;or even this
$CrystalReport.ParameterFields(2).AddCurrentValue (number("100"))



;Can't get this part to work (Passing in a Date)
$CrystalReport.ParameterFields(3).AddCurrentValue ("2007-09-01")

;Even grabbing the first defaultvalue from Crystal does not work
$CrystalReport.ParameterFields(3).AddCurrentValue ($CrystalReport.ParameterFields(3).getnthdefaultvalue(1))

Share this post


Link to post
Share on other sites



Well, I hope an answer appears soon. I've been wanting to do an AutoIt to CR interface for some time now. I thought about locating a VB dll that would convert a string to date that could be used within AutoIt. But then again, if someone were knowlegeable on how dates were stored in VB, they could probably create a small conversion routine in AutoIt.

Please share your findings with this forum,

Freedom1

Share this post


Link to post
Share on other sites

@All

You guess are working with CR XI as I can see.

I can't test this code because I am working with 8.5 unfortunately.

regards

ptrex

Ptrex,

I'm using CR X and have the same problem. Unfortunately 99% of my reports use date parameters.

Is there any type of testing or info I can provide to you to help us out of our dilemma short of sending you a copy of CR X? Is there a demo version of CR XI available?

Hopefully someone can resolve this issue. AutoIt is GREAT!!!

Freedom1

Share this post


Link to post
Share on other sites

@Freedom1

I think the fastest way to get this resolved is to find a Vbscript that uses a date parameter example.

And translate this script to au3.

When you run it post the error here and the script here.

Also a good way is searching the CR forum for examples.

The error can be in the AU3 but also in the way the CR accepts the date syntax. Hard to tell like this.

regards

ptrex

Share this post


Link to post
Share on other sites

I got the same problem. Is anyone can help us please?

Share this post


Link to post
Share on other sites

Try passing a string containing the CR date formula i.e. "Date(2008,08,21)"

I use this when passing parameters from PHP to a CR 8 website, it works fine in that situation.

Share this post


Link to post
Share on other sites

Were any of you able to open a crystal report and have it print automatically? I'm trying to create a script to have a crystal report print or export automatically.

Have any of you figured out how to pass the params??

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0