473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Unable to export Crystal report containing subreports

I have written an ASP/VB.Net application via VS 2003 (Crystal V9) that
uses MS Access 2000 as its database. I can export reports that have no
linked sub reports for printing. However, I'm unable to export reports
that have linked subreports. I receive (a "Missing parameter field
current value") on the following statement:

Me.crReportDocument.Export()

The main report requires 4 parameters. The linked reports do not
require any parameters other than the linking field.
Any suggestions/help appreciated.
Complete Code Listing:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Configuration.ConfigurationSettings
Public Class frmRptMPLCounty
Inherits System.Web.UI.Page

Public InternalOnly
Public CompFromDate
Public CompToDate
Public RptType

'CR Variables
Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterDiscreteValue As ParameterDiscreteValue

Dim crReportDocument As rptMasterPolicyListingCounty
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument

Dim Fname As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Populate report parameters
InternalOnly = Session("InternalOnly")
CompFromDate = Session("CompFromDate")
CompToDate = Session("CompToDate")
RptType = Session("RptType")
'Create an instance of the strongly-typed report object
crReportDocument = New rptMasterPolicyListingCounty

'Set the Report's SQL Connection
Me.SetSQLConnection()

'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = InternalOnly

'Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField
crParameterField.ParameterFieldName = "InternalOnly"
'Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDisc reteValue)

'Create an instance of the parameter fields collection, and pass
the discrete parameter with the discrete value to the
'collection of parameter fields.
crParameterFields = New ParameterFields
crParameterFields.Add(crParameterField)
'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = CompFromDate

'Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField
crParameterField.ParameterFieldName = "CompFromDate"
'Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDisc reteValue)

crParameterFields.Add(crParameterField)

'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = CompToDate

'Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField
crParameterField.ParameterFieldName = "CompToDate"
'Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDisc reteValue)

crParameterFields.Add(crParameterField)
'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterDiscreteValue.Value = RptType

'Define the parameter field to pass the parameter values to.
crParameterField = New ParameterField
crParameterField.ParameterFieldName = "RptType"
'Pass the first value to the discrete parameter
crParameterField.CurrentValues.Add(crParameterDisc reteValue)

crParameterFields.Add(crParameterField)
'The collection of parameter fields must be set to the viewer
CrystalReportViewer1.ParameterFieldInfo = crParameterFields

'Set the viewer to the report object to be previewed. This
'must be done after the parameter information has been set.
Me.CrystalReportViewer1.ReportSource = crReportDocument

'Refresh the report to ensure that the report retreives current
db info
Me.CrystalReportViewer1.RefreshReport()
End Sub

Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnPrint.Click
'Setup report parameter fields
Dim pFldDefs As ParameterFieldDefinitions
Dim pFldDef As ParameterFieldDefinition
Dim pValues As ParameterValues
Dim pDisValue As ParameterDiscreteValue
pFldDefs = crReportDocument.DataDefinition.ParameterFields

'Set the Report parameter
pFldDef = pFldDefs.Item("InternalOnly")
pValues = pFldDef.CurrentValues
pDisValue = New ParameterDiscreteValue
pDisValue.Value = Me.InternalOnly
pValues.Add(pDisValue)
pFldDef.ApplyCurrentValues(pValues)

pFldDef = pFldDefs.Item("CompFromDate")
pValues = pFldDef.CurrentValues
pDisValue = New ParameterDiscreteValue
pDisValue.Value = Me.CompFromDate
pValues.Add(pDisValue)

'Set the Report parameter
pFldDef = pFldDefs.Item("CompToDate")
pValues = pFldDef.CurrentValues
pDisValue = New ParameterDiscreteValue
pDisValue.Value = Me.CompToDate
pValues.Add(pDisValue)
pFldDef.ApplyCurrentValues(pValues)

pFldDef = pFldDefs.Item("RptType")
pValues = pFldDef.CurrentValues
pDisValue = New ParameterDiscreteValue
pDisValue.Value = Me.RptType
pValues.Add(pDisValue)
pFldDef.ApplyCurrentValues(pValues)

'Temporary file used for the export
Fname = AppSettings.Get("rptTempFile") &
Session.SessionID.ToString & ".doc"

Me.crDiskFileDestinationOptions = New DiskFileDestinationOptions

Me.crDiskFileDestinationOptions.DiskFileName = Fname

Me.crExportOptions = Me.crReportDocument.ExportOptions

With Me.crExportOptions
.DestinationOptions = Me.crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.WordForWindows
End With

Me.crReportDocument.Export()

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = "application/msword"

Response.WriteFile(Fname)

Response.Flush()

Response.Close()

'Delete the temp file
System.IO.File.Delete(Fname)
End Sub

Sub SetSQLConnection()

Dim crConnectionInfo As New ConnectionInfo
'Set the ConnectionInfo properties for logging on to the
Database

With crConnectionInfo
.ServerName = AppSettings.Get("rptServerName") ' <add
key="rptServerName" value="C:\PolicyTracking\PolicyTracking.mdb" />
End With

End Sub

Private Sub btnClose_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnClose.Click
Response.Redirect("frmRptMenu.aspx")
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
0 2668

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sean G. | last post by:
Howdy, I have a series of crystal reports, some have subreports, that I need to put together in one file on one click form the user. So put I imported the separate rpt files as subreports into...
1
by: Michael O'Donnell | last post by:
Hi All Am having major problem with crystal reports...Have designed my report no problem, its when I try to run and display ther report that I am getting a "Login Failed" message. At first I...
3
by: Edward | last post by:
ACCESS 2k I need to design a report based on a rota system for staff at various shops. The data is effectively stored in a single table, along the lines of: Initials (e.g. BH, FG, RM etc.)...
1
by: John | last post by:
Hi. Sir: Does anyboday know how to export subreport data using the export button in crystal report tool bar? We have a main report including a on-demand report. When we click the on-demand...
0
by: KartoffelKiffer | last post by:
Hello, i have to do a little Crystal Report task, where i need help. I have a mainreport in which are some subreports. The size of the subreports can vary so the subreport which could be bigger...
0
by: julie | last post by:
I have a CrystalReportViewer on a web page and when I click on the export button and select Word, the report opens in separate window in ..doc format, but the user cannot print / save as the...
0
by: julie | last post by:
I have a CrystalReportViewer on a web page and when I click on the export button and select Word, the report opens in a separate window in ..doc format, but the user cannot print or save as the...
3
by: LataChavan | last post by:
I have tried to look for a solution to the problem of sending parameters to stored procedures through crystal report. Following is the code: Now what happens is that if i do not apply the logon...
2
by: Franck | last post by:
Ok i have a problem. What do i need to change to make crystal show subreport within subreports ? So i have 3 layer The MainReport Multiple SubReport Attached in the MainReport Multiple...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.