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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this the right way to pass parameters from ASP to CR 8.5?

Status
Not open for further replies.
Oct 11, 2006
300
US
'This line creates an object to reference the first parameter in the report.
'strEmpID which is numeric should be equal to ?EmpID. Hence cast as double of type number 7. (See the chart below)
set Param1 = session("ParamCollection").Item(2)
'NewParamValue = "?EmpID"
NewParamValue = strEmpID
Call Param1.SetCurrentValue(CDbl(NewParamValue),7)

'This line creates an object to reference the 2nd parameter in the report.
'Period is datetime. Hence cast as double of type number 10. (See the chart below)

set Param2 = session("ParamCollection").Item(2)
'NewParamValue = "?Post Date"
NewParamValue = strPeriod
Call Param2.SetCurrentValue(CDate(NewParamValue),10)

I cannot see any report data - so I am guessing that no parameters were passed. Please guide me here. If I need to use a different method altogether.
 
Here is an example of how I set parameters from ASP for CR 8.5

Set ParamDefCollection = Session("oRpt").Parameterfields
Set session("Param") = ParamDefCollection

Set MyParam1 = session("Param").Item(1)
MyNewParamValue1 = Request.Form("Whse")
Call MyParam1.SetCurrentValue(CSTR(MyNewParamValue1),12)

Set MyParam2 = Session("Param").Item(2)
splitdate = split(Request.Form("CountDate"),"/")
MynewDate1 = splitdate(2) & "/" & splitdate(0) & "/" & splitdate(1) & " 12:00:00 AM"
MyParam2.SetCurrentValue CDate(MynewDate1)


You can also add the parameter fields to your report to verify that they are getting the correct values.
 
Hey Jason,

How do I add a parameter to the report?

Is not ?Post Date and ?Empid which are added in the report header of the report a parameter?

Thanks.
 
Sorry, by add the paramter field to the report I meant that if you are not getting any data on the report you should at least display the parameter on the report (by dragging it from the Field Explorer to the Page Header) so you can see if the parameter is getting populated correctly. The parameter may be getting set correctly but you are not getting data due to some other issue.
 
As suggested, I moved the parameters from the hidden report header to the unhidden page header.

Now from ASP front, when I did this, I get errors:

When I look into the source of my dropdown box, my date looks like this: 4/30/2006

Above is pulled from SQL Server 2005.

Now in my ASP page, I wrote this:

'This line creates an object to reference the 2nd parameter in the report.
'Period is datetime. Hence cast as double of type number 10. (See the chart below)

Set MyParam2 = Session("Param").Item(2)
splitdate = split(Request.form("Period"), "/")
MynewDate1 = splitdate(2) & "/" & splitdate(0) & "/" & splitdate(1) & " 12:00:00 AM"
MyParam2.SetCurrentValue CDate(MynewDate1)

When I run this, my IE browser mentions this error:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch
/scripts/ViewReports.asp, line 112

Where line 112 refers to:

MyParam2.SetCurrentValue CDate(MynewDate1)

I even tried this:

MyParam2.SetCurrentValue(CDate(MynewDate1,10))

I get the following error.

Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'CDate'
/scripts/ViewReports.asp, line 113

So what error am I making?

Thanks.
 
Hey Jason,

To solve the issue of sending my parameters, I created a simple test report with the 2 parameters of the report:

?EmpID
?Post Date

On the page header just to check if my parameters are working fine. First time I passed an employee ID, I was able to see the results in the report.

Just to test it more, I selected another employee, but my report still shows the name of the 1st employee. How can I make the report reflect the change in parameters everytime I send a new one from ASP.

Thanks for helping on the previous parameters question. I appreciate it.

 
Hey Jason,

Any ideas about this CDate

I am still getting this error of Date and employee now refreshing. Any ideas?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top