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

AlwaysRequiredSteps.asp......

Status
Not open for further replies.

qberta01

Programmer
Nov 14, 2005
113
Hello,

I use the AlwaysRequiredSteps.asp to open the necessary objects and pass parameters to my Crystal report. It all works fine. However, I would like to reuse the same AlwaysRequiredSteps.asp for my other Crystal reports that have different input parameters. For some reason, the page does not like it and gives me an error. Hence, I had to create a separate AlwaysRequiredSteps.asp page using only the parameters called for in one report.

Is there a way to alter AlwaysRequiredSteps.asp so it can sucessfully process many reports with varying parameters?

I am using classic ASP and Crystal 11 developer.

Thx,

Q
 
Oh and ignore:

dim iIntMax : iIntMax = 0

meant to delete that too (stuck in traffic for 2 hours this morning - not thinking straight) :)


 
Hi,

I get an error at this line:

Code:
'/// Collect the Values wanted into the dictionary object

for i= lbound(aParams) to ubound(aParams)
    aKeyValue = split(aParams(i),"=")
    sIDX = aKeyValue(lbound(aKeyValue))
    sParam = aKeyValue(ubound(aKeyValue))
    dList.add sIDX, sParam
next
[b]    dList.Remove("CommissionStatement")[/b]

I get an error "Element not found"

Can you post the entire page code, if possible?

Thanks.
 
Hi - maybe you can print out the values from the dictionary to make sure the names are correct.

Maybe CommissionStatement does not exist in the dictionary?

<%

dim rpt

Rpt=request.QueryString("Report")

' ALways requires steps......
' CREATE THE APPLICATION OBJECT
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.11")
End If

' CREATE THE REPORT OBJECT
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend

'OPEN THE REPORT (but destroy any previous one first)
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if

On error resume next

Set session("oRpt") = session("oApp").OpenReport(path & Rpt, 1)
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.

If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
End If

session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False


dim sStr
sStr = request.QueryString
dim aParams : aParams = split(sStr, "&")
dim aKeyValue, i, sIDX
dim iIntMax : iIntMax = 0
dim sparam, Keys, Items

dim dList : set dList = Server.CreateObject("Scripting.Dictionary")

'/// Collect the Values wanted into the dictionary object

for i= lbound(aParams) to ubound(aParams)
aKeyValue = split(aParams(i),"=")

sIDX = aKeyValue(lbound(aKeyValue))
sParam = aKeyValue(ubound(aKeyValue))

dList.add sIDX, sParam
next
dList.Remove("Report")

'Get dictionary Keys
Keys = Dlist.Keys

'Get dictionary Items
Items = DList.Items

'Loop through Keys array
For iCount = 0 To UBound(Keys)
param=Keys(iCount)
crystalparam=Items(iCount)
Session("oRpt").ParameterFields.GetItemByName(param).AddCurrentValue(crystalparam)
Next

'/// Clean up
set dList = nothing

'Create a reference to the tables collection of the main report
Set mainReportTableCollection = Session("oRpt").Database.Tables

For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("user ID") = "SQLAdmin"
.Item("Password") = "xxxx"
.Item("DSN") = "Reports"
.Item("Database") ="Reports"
End With
Next

session("oRpt").ReadRecords

If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine

End If

%>

<!-- #include file="SmartViewerActiveX.asp" -->





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top