473,390 Members | 1,091 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,390 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 2669

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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.