Jump to content

Crystal Reports and Date Parameters


Recommended Posts

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))
Link to comment
Share on other sites

  • 3 months later...

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

Link to comment
Share on other sites

  • 3 weeks later...

@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

Link to comment
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

Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...
  • 4 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...