Results 1 to 5 of 5

Thread: ***RESOLVED***This array must be subscripted.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Sunny Scottsdale Arizona
    Posts
    254

    ***RESOLVED***This array must be subscripted.

    I am passing multiple parameters (ID's) using an array to a Crystal Report. I am receiving the following message when running my code:

    "Crystal Report Viewer"

    "This array must be subscripted. For example: Array [i]."

    Here is my code:
    Code:
    Private Sub SettleSched_Par()
    
        Dim strInput As String
        Dim strValues() As String
        Dim i As Integer
            
        '--------Encapslulated code opens cr report--------
        Dim Report As New rptFundBuySched
        Dim crPDefs As CRAXDRT.ParameterFieldDefinitions
        Dim crPDef As CRAXDRT.ParameterFieldDefinition
    
        Set crPDefs = Report.ParameterFields
        
        For Each crPDef In crPDefs
            With crPDef
                Select Case .ParameterFieldName
                    Case "TradeIDParm"
                        'Get the ID's.
                        strInput = InputBox("Enter trade ID's seperated by commas.", "Enter Trade ID's")
                        
                        'Split them into an array.
                        strValues = Split(strInput, ",")
                        
                        'Add parameter(s).
                        For i = 0 To UBound(strValues)
                            .AddCurrentValue CDbl(strValues(i))
                        Next i
                End Select
            End With
        Next
    
        Report.EnableParameterPrompting = False
        frmRptView.CRViewer1.ReportSource = Report
        frmRptView.Show
        frmRptView.CRViewer1.ViewReport
        '-------------------------------------------------
    
    End Sub
    I have the parameter in the report set to 'Allow Multiple Values'.

    Help appreciated. Thx
    Last edited by Jefftopia; Jul 30th, 2007 at 03:52 PM.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: This array must be subscripted.

    Check the report formulas. TradeIdParm is now an array so any existing references you had in formulas need to be modified as well.

    For example, the Record Selection Formula may have been

    {TradeId} = {?TradeIdParm}

    it would have to change to

    {TradeId} In {?TradeIdParm}

    Another formula example

    "Trade Id " + ToText({?TradeIdParm}, 0)
    will become
    "Trade Id " + ToText({?TradeIdParm}[2], 0)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Sunny Scottsdale Arizona
    Posts
    254

    Re: This array must be subscripted.

    I am sooo close. Here is the formula:

    [formula]
    if {?TradeIDParm} > 0 then
    {ado.Trade_id} In {?TradeIDParm}
    [/formula]

    I changed {ado.Trade_id} = {?TradeIDParm} as you suggested to {ado.Trade_id} In {?TradeIDParm. This seems to work well.

    What do I need to change {?TradeIDParm} > 0 to?

    If I can get that this whole thing is solved.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2002
    Location
    Sunny Scottsdale Arizona
    Posts
    254

    Re: This array must be subscripted.

    Why does "Trade Id" + ToText({?TradeIDParm},0) become "Trade Id" + ToText({?TradeIdParm}[2],0)?

    How would I show the criteria {?TradeIDParm}>0?

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: This array must be subscripted.

    Any parameter that accepts multiple values is an Array. When using Crystal Syntax, the array subscript operator is the square brackets. Basic syntax requires the parenthesis.

    How would I show the criteria {?TradeIDParm}>0?
    Depends which array element you are comparing to 0

    {?TradeIDParm}[1]>0

    Note: Crystal Arrays are 1 based.

    If you are trying to make the parameter optional the record selection formula would need to be something like

    Code:
    If {?TradeIDParm}[1] > 0 Then
       {ado.Trade_id} In {?TradeIDParm}
    Else
       {ado.Trade_id} > 0

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