Results 1 to 3 of 3

Thread: [Resolved] Passing Multiple Parameters w/CR & VB 2005

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Posts
    18

    Resolved [Resolved] Passing Multiple Parameters w/CR & VB 2005

    Hello

    I have searched for how to pass multiple parameters and have found a way but I still get prompted to enter all but one of the multiple parameters. Which ever parameter I add to my parameter list last is the winner, all others I must enter via the prompt dialog. Here's the code:

    Code:
            Dim paramFields As New CrystalDecisions.Shared.ParameterFields
            Dim paramField As New CrystalDecisions.Shared.ParameterField
            Dim paramFieldRange As New CrystalDecisions.Shared.ParameterDiscreteValue
    
            Me.crvReportViewer.ReportSource=rptSource
    
            paramField.Name = "@datStart"
            paramFieldRange.Value = gdatReportStartDate
            paramField.CurrentValues.Add(paramFieldRange)
            paramFields.Add(paramField)
    
            MsgBox(paramField.Name.ToString())
    
            paramField.Name = "@datEnd"
            paramFieldRange.Value = gdatReportEndDate
            paramField.CurrentValues.Add(paramFieldRange)
            paramFields.Add(paramField)
    
            paramField.Name = "@txtUser"
            paramFieldRange.Value = System.Environment.UserName
            paramField.CurrentValues.Add(paramFieldRange)
            paramFields.Add(paramField)
    
            Me.crvReportViewer.ParameterFieldInfo = paramFields
            Me.crvReportViewer.Refresh()
    What I see in the autos window is that paramfields has three items and that all three are exactly the same. I know that this is the issue, but how do I get the paramfields to contain the three different parameters? Does this have something to do with using the ParameterDiscreteValue? Thanks
    Last edited by katuil; Aug 23rd, 2007 at 04:34 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Passing Multiple Parameters w/CR & VB 2005

    put this after you add the parameter, before you set the name on the next one.

    Code:
    paramField = New CrystalDecisions.Shared.ParameterField
    What's happening is that you are recylcing the same object, instead of creating new ones.... so each parameter you "add" simply points to the last one by name. By creating a new instance after adding the previous one, the problem should go away.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Posts
    18

    Re: Passing Multiple Parameters w/CR & VB 2005

    Thanks for the obvious. I also found that paramFieldRange was creating a problem as well. I set up three separate parameter field ranges because one was still pushing in the last value into all three parameters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width