Link to home
Start Free TrialLog in
Avatar of chuyan
chuyan

asked on

passing parameters to crystal report

i'm using Crystal Report 8.0 with VB6.

I have create a report and which gets data from a MS-SQL stored proc.
That stored proc. requires 4 parameters,
so I put the following statements in my program:

With CrystalReport1
        .Connect = ODBCSTRING
        .ReportFileName = App.Path + "\rptdelioffice.rpt"
        .ParameterFields(0) = "ord_date;date(2000,7,10);true"
        .ParameterFields(1) = "dist_code_from;   ;true"
        .ParameterFields(2) = "dist_code_to;zzz;true"
        .ParameterFields(3) = "fcompany;0;true"
        .Action = 1
end with

However, I just receive an error msg:

Run-tim error '20553'
Invalid parameter field name

I'm sure that the field names of the parameters are correct, I just not sure if the syntax of passing the parameter field values is correct.

Could anybody help me?
Avatar of ivanc
ivanc

chuyan

Maybe you can try replacing the true with 1

ParameterFields(1) = "dist_code_from;   ;1"

HOpe this helps

Ivanc
Avatar of chuyan

ASKER

Adjusted points from 50 to 100
Avatar of chuyan

ASKER

Ivanc,

Thanks for your help.  However, It doesn't solve the problem by replace "true" with "1".  The syntax I used is referenced from the help file "Developr.hlp" in CR8.  I don't know why it keeps prompting me error.

Chuyan

I would think why don't you try passing one parameter at each time.  I am not sure but I suspect the error is spawned from this line
ParameterFields(1) = "dist_code_from;   ;1"

Ivanc
Avatar of chuyan

ASKER

I'm going to have my problem solved now.  I found that there is a property for CR control named "StoredProcParam".
This property is for used with the reports based on SQL stored proc.
I can pass the parameters by setting this property.  However, my problem is not 100% solved.  I can pass char / num type parameters, but can't pass date type parameter.  I have tried several different syntax but still can't do it.

The statement below is copied from help file:
CrystalReport1.StoredProcParam(0) = "06/14/1989"

I got a parameter in SQL stored proc which is type of "smalldatetype" (and actually I only concern the date part).
I followed the above syntax, but I got an error message:
Run-time error '20650':
Error in file d:\abc\abc.rpt:
The specified value type is different to the current value type.

I can pass other parameters with problem, and if I remark the statement which passing the date parameter, I won't get any error message.  And I just receive a prompt for the date parameter.  Now my problem is how to pass the date type parameter to CR.

It's quite urgent, please help.
Thanks alot.


chuyan

I think that crystal does not accept these type of format as it is expecting a string.  May be you can try this.

CrystalReport1.StoredProcParam(0) = "date(1989,06,14)"

Hope this helps

Ivanc
Avatar of chuyan

ASKER

oh sorry, I didn't work too.

Avatar of chuyan

ASKER

oh sorry, I didn't work too.

ASKER CERTIFIED SOLUTION
Avatar of mdougan
mdougan
Flag of United States of America image

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
Hello?
Avatar of chuyan

ASKER

mdouqan,

I post another question.  Would you help?