473,769 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.crReportDocu ment.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 CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.Shared
Imports System.Configur ation.Configura tionSettings
Public Class frmRptMPLCounty
Inherits System.Web.UI.P age

Public InternalOnly
Public CompFromDate
Public CompToDate
Public RptType

'CR Variables
Dim crParameterFiel ds As ParameterFields
Dim crParameterFiel d As ParameterField
Dim crParameterDisc reteValue As ParameterDiscre teValue

Dim crReportDocumen t As rptMasterPolicy ListingCounty
Dim crExportOptions As ExportOptions
Dim crDiskFileDesti nationOptions As DiskFileDestina tionOptions
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObje ct As SubreportObject
Dim subRepDoc As New ReportDocument

Dim Fname As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'Populate report parameters
InternalOnly = Session("Intern alOnly")
CompFromDate = Session("CompFr omDate")
CompToDate = Session("CompTo Date")
RptType = Session("RptTyp e")
'Create an instance of the strongly-typed report object
crReportDocumen t = New rptMasterPolicy ListingCounty

'Set the Report's SQL Connection
Me.SetSQLConnec tion()

'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDisc reteValue = New ParameterDiscre teValue
crParameterDisc reteValue.Value = InternalOnly

'Define the parameter field to pass the parameter values to.
crParameterFiel d = New ParameterField
crParameterFiel d.ParameterFiel dName = "InternalOn ly"
'Pass the first value to the discrete parameter
crParameterFiel d.CurrentValues .Add(crParamete rDiscreteValue)

'Create an instance of the parameter fields collection, and pass
the discrete parameter with the discrete value to the
'collection of parameter fields.
crParameterFiel ds = New ParameterFields
crParameterFiel ds.Add(crParame terField)
'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDisc reteValue = New ParameterDiscre teValue
crParameterDisc reteValue.Value = CompFromDate

'Define the parameter field to pass the parameter values to.
crParameterFiel d = New ParameterField
crParameterFiel d.ParameterFiel dName = "CompFromDa te"
'Pass the first value to the discrete parameter
crParameterFiel d.CurrentValues .Add(crParamete rDiscreteValue)

crParameterFiel ds.Add(crParame terField)

'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDisc reteValue = New ParameterDiscre teValue
crParameterDisc reteValue.Value = CompToDate

'Define the parameter field to pass the parameter values to.
crParameterFiel d = New ParameterField
crParameterFiel d.ParameterFiel dName = "CompToDate "
'Pass the first value to the discrete parameter
crParameterFiel d.CurrentValues .Add(crParamete rDiscreteValue)

crParameterFiel ds.Add(crParame terField)
'Create a new instance of a discrete parameter object to set the
first value for the parameter.
crParameterDisc reteValue = New ParameterDiscre teValue
crParameterDisc reteValue.Value = RptType

'Define the parameter field to pass the parameter values to.
crParameterFiel d = New ParameterField
crParameterFiel d.ParameterFiel dName = "RptType"
'Pass the first value to the discrete parameter
crParameterFiel d.CurrentValues .Add(crParamete rDiscreteValue)

crParameterFiel ds.Add(crParame terField)
'The collection of parameter fields must be set to the viewer
CrystalReportVi ewer1.Parameter FieldInfo = crParameterFiel ds

'Set the viewer to the report object to be previewed. This
'must be done after the parameter information has been set.
Me.CrystalRepor tViewer1.Report Source = crReportDocumen t

'Refresh the report to ensure that the report retreives current
db info
Me.CrystalRepor tViewer1.Refres hReport()
End Sub

Private Sub btnPrint_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnPrint.Click
'Setup report parameter fields
Dim pFldDefs As ParameterFieldD efinitions
Dim pFldDef As ParameterFieldD efinition
Dim pValues As ParameterValues
Dim pDisValue As ParameterDiscre teValue
pFldDefs = crReportDocumen t.DataDefinitio n.ParameterFiel ds

'Set the Report parameter
pFldDef = pFldDefs.Item(" InternalOnly")
pValues = pFldDef.Current Values
pDisValue = New ParameterDiscre teValue
pDisValue.Value = Me.InternalOnly
pValues.Add(pDi sValue)
pFldDef.ApplyCu rrentValues(pVa lues)

pFldDef = pFldDefs.Item(" CompFromDate")
pValues = pFldDef.Current Values
pDisValue = New ParameterDiscre teValue
pDisValue.Value = Me.CompFromDate
pValues.Add(pDi sValue)

'Set the Report parameter
pFldDef = pFldDefs.Item(" CompToDate")
pValues = pFldDef.Current Values
pDisValue = New ParameterDiscre teValue
pDisValue.Value = Me.CompToDate
pValues.Add(pDi sValue)
pFldDef.ApplyCu rrentValues(pVa lues)

pFldDef = pFldDefs.Item(" RptType")
pValues = pFldDef.Current Values
pDisValue = New ParameterDiscre teValue
pDisValue.Value = Me.RptType
pValues.Add(pDi sValue)
pFldDef.ApplyCu rrentValues(pVa lues)

'Temporary file used for the export
Fname = AppSettings.Get ("rptTempFil e") &
Session.Session ID.ToString & ".doc"

Me.crDiskFileDe stinationOption s = New DiskFileDestina tionOptions

Me.crDiskFileDe stinationOption s.DiskFileName = Fname

Me.crExportOpti ons = Me.crReportDocu ment.ExportOpti ons

With Me.crExportOpti ons
.DestinationOpt ions = Me.crDiskFileDe stinationOption s
.ExportDestinat ionType = ExportDestinati onType.DiskFile
.ExportFormatTy pe = ExportFormatTyp e.WordForWindow s
End With

Me.crReportDocu ment.Export()

Response.ClearC ontent()

Response.ClearH eaders()

Response.Conten tType = "applicatio n/msword"

Response.WriteF ile(Fname)

Response.Flush( )

Response.Close( )

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

Sub SetSQLConnectio n()

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

With crConnectionInf o
.ServerName = AppSettings.Get ("rptServerName ") ' <add
key="rptServerN ame" value="C:\Polic yTracking\Polic yTracking.mdb" />
End With

End Sub

Private Sub btnClose_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnClose.Click
Response.Redire ct("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 2726

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

Similar topics

0
2292
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 one big master report. Now I know crystal doesn't support subreports in subreports. If the lowest level subreports existed as rpt files, I could import them into the master report and use grouping to make it look like the subreports in the...
1
334
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 thought it might have to do with the regristration key, but that ok, when I right click on Servers in the server explorer and then expand the Crystal Server, there is a red x beside the Crystal Enterprise. When I click on log in, I am asked for a
3
3354
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.) Day (e.g. Monday, Tuesday etc.) Shop (e.g. Shop1, Shop2 etc.) StartTime (e.g. 8, 13 etc.)
1
3941
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 button, the page show the subreport detail, that's fine. but when i click the export button on crystal report tool bar, the page automatically go to the main report and export main report. Does anybod know how to do that?
0
2393
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 than before overlap the other subreports. Is it psossible that the subreports are fixed an when they need more place the size could be bigger ? I hope my english is ok, so you can help me :?
0
1195
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 standard word toolbar / menubar is not available. Toolbars and menus are also missing when I export to other formats e.g. excel and rich text format (pdf is ok). Any ideas how to export the report in Word and see the usual Word toolbars and menu...
0
1186
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 standard word toolbar and menubar is not available. Toolbars and menus are also missing when I export to other formats e.g. excel and rich text format (pdf is ok). Any ideas how to export the report in Word and see the usual Word toolbars and...
3
9923
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 information the crystal reports works fine by accepting the parameter values and giving the Database Logon prompt when we run the report. But I would like to give the logon information at runtime. If I give the info at runtime the "stored procedure"...
2
2871
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 SubSubReport Attached in the SubReports Showing the SubReport itself by bypassing the MainReport the SubSubREport are showing
0
9586
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.