Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a parameter

Status
Not open for further replies.

djpatrick

Programmer
Aug 27, 2002
7
US
Crystal Reports is new to me so excuse the questions if they are simple. I am trying to pass a date parameter and get an error saying:

Invalid parameter field value

Here is the code:

strProcessDate = "08/20/02"
frmCreate.CrystalReport1.ReportFileName = "D:\NonDiff.rpt"

frmCreate.CrystalReport1.ParameterFields(0)
= "@ProcessDate; DATETIME(" & CDate(strProcessDate) & ",0,0,0);True"

frmCreate.CrystalReport1.Action = 1
frmCreate.CrystalReport1.PrintReport

What am I doing wrong. I looked at this site to find others having a similar problem and tried using the advice given to them, however, it is not working for me.

Thanks in advance

Don
 
Hey man, I'm having the same problem you are and I'm having one heck of a time trying to solve it. I posted a thread in Crystal Reports 4 Other topics section, in case you want to check it out, but I don't have any good replies as of yet. Good luck! I just wanted to let you know I'm stuck here too,

Jacob Schroeder
 
hey man, check this out... I found this in the help files... hopefully it works for you... it didn't for me, let me know what happens...

Usage

[form.]Report.ParameterFields(ArrayIndex)[="ParameterName;
NewValue;SetCurrentValue"]

Remarks

¨ The parameter, SetCurrentValue can either be set to TRUE or FALSE.

¨ If set to TRUE, the parameter value is passed to the current value in the report; the user is not prompted to enter the parameter value.

¨ If set to FALSE, the parameter value is passed to the default value for the parameter; the user is prompted to enter the parameter value, with the value you set showing as the default value.

¨ The default value for SetCurrentValue is FALSE.

¨ This property does not eliminate the prompt by specifying a current value for the parameter field. You will still be prompted but the default value in the prompt will be the value you specify.

¨ Use a separate line of code for each parameter field for which you want to change the value.

¨ The order of values in the array must conform to the order of parameter fields in the report.

¨ The first parameter field in the report is array index (0), the second is (1), etc.

¨ For example, to change the value of the first parameter field in a report (parameter1) to "red" use the following syntax (user will not be prompted to enter a value):

CrystalReport1.ParameterFields(0) = "parameter1;red;TRUE"

¨ Or, to prompt the user to change the value of the third parameter field in a report (parameter3) use the following syntax (user will be prompted to use the default value set using the NewValue parameter below - "blue"):

CrystalReport1.ParameterFields(2) = "parameter3;blue;FALSE"
 
Ok, the method mentioned above is working for me, however, I think my problem is the fact that the parameter field name is two words separated by a space. All my single-word parameters work fine using the method above, however, for my "Start Date" and "End Date" parameters, I am having problems here. Is there a trick that I should know?

Jacob438
 
...sorry for posting so much, I'm just posting as I'm learning, and I'm very frustrated with crystal at this point... anyways, it doesn't have to do with two word parameters, because some of my other two word parameters work fine... I'm looking into it, but my guess now is that it probably has something to do with the fact that the two parameters that aren't working for me are Date fields, of type "date" in Crystal. So now I just need to figure out how to pass those in, hope this will be helpful to you when you check back here,

later dude,

Jacob
 
Allright, I fixed it... I guess the activeX index for parameterfields is 1 based (at least it is for me... when I use 0 I get an error). I thought I saw a post on here that said it was 0 based index? Oh well, in my case, it definately isn't. Also, I noticed something funny, as long as I have the ParameterName correct when I pass in the string, it doesn't care which index I use (as long as it's not 0), strange huh? Well, if anybody has any explanations about the weird things I noticed, please enlighten me. Later dudes,

Jacob
 
I think you want something like

"@ProcessDate;DATETIME(" & Format(CDate(strProcessDate), "yyyy,m,d") & ",0,0,0);True"

I do not use the OCX control only RDC (do not even load it) but in the past when I used I believe crystal is looking for the parameter to look like
DATETIME(year,month,day,hour,minute,second). That is why it is complaining.
 
yeah, that's similar to what I used... here's what I did and it's working...

CrystalReport1.ParameterFields(1) = "Begin Date;Date(2002,08,01);TRUE"

Thanks for the reply,

Jacob438
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top