Advertisement

06.18.2008 at 08:31AM PDT, ID: 23495617
[x]
Attachment Details

Passing parameters to a crystal report for export using VB.Net (i.e. not using a viewer)

Asked by braney in Microsoft Visual Basic.Net, Crystal Reports Software

Tags: vb.net crystal, Private Sub SetCurrentValuesForParameterField(ByVal myReportDocument As ReportDocument, ByVal strParameterName As String, ByVal strParameterValue As String)

Most of the time when I'm copying code from the internet, I try to understand how the code works.
I understand how to pass parameters to a report viewer fine, but this section of code is a bit trickier to understand. I did get it working in it's current form, but now it doesn't seem to work for all reports.

For reports that use our main database and TableLogOnInfo, it works fine. However I get the error when I pass through my own dataset.

The error is this:
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
The error is on this line:
Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(strParameterName)

If you need to see any more code, please let me know. Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Private Sub SetCurrentValuesForParameterField(ByVal myReportDocument As ReportDocument, ByVal strParameterName As String, ByVal strParameterValue As String)
 
        Dim currentParameterValues As ParameterValues = New ParameterValues()
 
        Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
        myParameterDiscreteValue.Value = strParameterValue
        currentParameterValues.Add(myParameterDiscreteValue)
 
        Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
 
        Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(strParameterName)
 
        myParameterFieldDefinition.ApplyCurrentValues(currentParameterValues)
 
    End Sub
[+][-]06.18.2008 at 08:45AM PDT, ID: 21814127

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.18.2008 at 08:46AM PDT, ID: 21814133

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.18.2008 at 12:37PM PDT, ID: 21816289

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Crystal Reports Software
Tags: vb.net crystal, Private Sub SetCurrentValuesForParameterField(ByVal myReportDocument As ReportDocument, ByVal strParameterName As String, ByVal strParameterValue As String)
Sign Up Now!
Solution Provided By: braney
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628