Parameter Fields, Crystal Reports

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Parameter Fields, Crystal Reports

Post by D Willett »

I need to pass values into parameters using the Crystal controls as follows:

Report.ParameterFields(1).AddCurrentValue ("Wednesday")
Report.ParameterFields(2).AddCurrentValue Val(Text2)
Report.ParameterFields(3).AddCurrentValue (0)
Report.ParameterFields(4).AddCurrentValue ("")

Which is fine if the report requires 4 parameters. If the report only needs 3 then if the order of the parameters is incorrect then the project falls over.
So I'm thinking I need to find the parameter field name so I can set a value accordingly.
I'm thinking a select case statement:

'This is just air code.............
Select Case report.parameterfields.name
case1 "DayID"
Report.ParameterFields(1).AddCurrentValue ("Wednesday")
case2 "Amount"
Report.ParameterFields(2).AddCurrentValue Val(Text2)
end select

Does anyone have any experience with the Crystal controls to help me out ?

Regards
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78558
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Parameter Fields, Crystal Reports

Post by HansV »

Try

Report.ParameterFields.GetItemByName("DayID").AddCurrentValue "Wednesday"
Report.ParameterFields.GetItemByName("Amount").AddCurrentValue Val(Text2)

etc.
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Parameter Fields, Crystal Reports

Post by D Willett »

Hi Hans, great stuff.
I'm getting Error: method or data not found with [.GetItemByName] although I've registered CRAXDRT.dll ??
Have you tested the lines of code? or any thoughts on this?

Regards
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78558
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Parameter Fields, Crystal Reports

Post by HansV »

Hi Dave,

It was just something I found by Googling. I don't have Crystal Reports myself, so I have no idea what would be needed. Sorry.
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Parameter Fields, Crystal Reports

Post by D Willett »

:scratch: I did the same, I'll find a way as I always do.... lol
Cheers ...

Dave.