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

I'm so close, it's killing me

Status
Not open for further replies.

profFrink

Programmer
Dec 11, 2002
3
0
0
US
Ok, I'm new to Crystal Reports(9.0) Developer. This report prompts me for a parameter, agent code, which is text, 8 characters. Works great as a stand alone report. What I want to do is move it up to the web(see code below), which I was able to do no problem when it wasn't parameter based. Now, I want to be able to drop a paramter in there via asp based on whatever the user chooses, I've been all over the place looking for answers and Crystals site is the worse train wreck I've ever seen. Anybody?!

dim objfactory,rptviewer
set objfactory=server.CreateObject("CrystalReports.ObjectFactory.2")
set rptviewer=objfactory.CreateObject("CrystalReports.CrystalReportViewer")
'set rptviewer=objfactory.CreateObject("CrystalReports.CrystalReportServerControl")
rptviewer.IsOwnPage=True
rptviewer.ReportSource="Femenella1.rpt"
rptviewer.processHTTPrequest request,response
 
Hope this sheds some light on the subject. You need to make a call to your rptviewer. Check out the code below.

<%@ Language=VBScript%>
<%
Response.ExpiresAbsolute = Now() - 1
Session.CodePage = 65001 ' UTF-8

Dim objFactory 'Use the ObjectFactory object to abstract the version number to one location
Set objFactory = CreateObject(&quot;CrystalReports.ObjectFactory.2&quot;)

Const REPORTSOURCEPARAM = &quot;reportsource&quot;
Const CRREPORTSOURCE = &quot;CrystalReportReportSource&quot;

Sub OutputReport()
' DESCRIPTION : Use the web report viewer to view the report specified by the &quot;reportsource&quot;
' request parameter
Dim reportSource
Dim viewer

Dim requestMethod
requestMethod = UCase(Request.ServerVariables(&quot;REQUEST_METHOD&quot;))

Select Case requestMethod
Case &quot;POST&quot;
reportSource = Request.Form(REPORTSOURCEPARAM)
Case &quot;GET&quot;
reportSource = Request.QueryString(REPORTSOURCEPARAM)
Case Else
reportSource = Empty
End Select

' View report
If (IsEmpty(reportSource)) Then
reportSource = Session(CRREPORTSOURCE)
End If

If Not (IsEmpty(reportSource)) Then
Session(CRREPORTSOURCE) = reportSource

Set viewer = objFactory.CreateObject(&quot;CrystalReports.CrystalReportViewer&quot;)

With viewer
.ReportSource = reportSource
.IsOwnPage = false
.HasRefreshButton = true
.Name = &quot;HTML Page Viewer&quot;
End With

Call viewer.ProcessHttpRequest(Request, Response, Session)
End If

if Err.number <> 0 then
Response.Write Err.Description
Err.Clear
end if

Set viewer = nothing
End Sub

%>

<html>
<body bgColor=&quot;white&quot;>
<% OutputReport %>
</body>
</html>
 
Ok, that's great for displaying the report, but what I'm not sure of is where/how to pass parameters to it from the page. Here's what I mean. The parameter the report needs, is an agent code, let's say the agent code is SCADC44X. and the parameter name is &quot;agent&quot;. How do I pass this to the report so that it pulls for the agent my user selected?
 
Hi,

I don't use CR9, but I have used CR8.0 and CR8.5, I have a link below, which contains parameter calling method, hope it help.


thread149-355777
 
If you are using the CrystalReportsInteractiveViewer object, you should see the prompt for the parameter on the screen just before the report is rendered.
 
Scratch that last comment. I wasn't reading the whole thing correctly. First you have to open the report so that you can modify it. Then you have to make a copy of the parameter, then modify the copy. After that you have to replace the existing parameter value with the copy. Then pass the report into the viewer. I'll have a better sample of code tomorrow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top