Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array must be subscripted

Status
Not open for further replies.
Mar 26, 2013
10
US
I am using Crystal 2008 and my data is coming from sql server.
I have a crystal report that prompts the user for a month.
The parameter is defined as a number and is dynamic. I also have it set to true to allow multiple values.
Once this is selected, I need to for the report to show the following fields:
current month, previous months and 2 months prior.

In the current month formula, i'm trying to use a select statement to capture the values I want.

Current Month:
Select ({?Date})
Case 1 :
{@Month 1}
Case 2 :
{@Month 2}
Case 3 :
{@Month 3}
etc....

For the previous month formula, I would use the same select statement, except it will be
Select ({?Date}-1).

Problem is that I get an error that says : This array must be subscripted.
Can someone help me out.

Thanks
 
The reason the select is throwin the array error is because once you set your parameter to allow multiple values it becomes an array. Take the allow multiple value out and you shouldn't get that error anymore. But I think you should consider changing your approach. Leaving your parameter setup like you had it try

if month({yourtable.yourdatefield}) in {?Date}

A little more info about your setup will probably result in an even better solution to return the months you are trying to return



_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
CoSpringsGuy,
Thanks. I was able to resolve the array issue by removing the multiple values option from the parameter.

I am trying to get the user to input the month they would like to see; which would be the current month, and also show the 2 previous months.

Each month has a formula like:
if year(currentdate) = {GLTRANS.FISCAL_YEAR} and {GLTRANS.ACCT_PERIOD} = 1 then {GLTRANS.TRAN_AMOUNT}

I then created 3 additional formulas; current month, previous month, and double prior month.
Each of these formulas has the following formulas:
Current Month Previous Month Double Prior Month
Select ({?Date}) Select ({?Date}-1) Select ({?Date}-2)
Case 1 : etc... etc....
{@Period 1}
Case 2 :
{@Period 2}
Case 3 :
{@Period 3}

I can get the current month formula to work, but the other 2 don't.
Also, I'm tyring to figure out how to get everything to work if the user enters 1 for January for the current month.
I would need the Previous Month to be December of the prior year and Double Prior to be November of the prior year.

Thanks for all the help
 
are there other date fields available to you? like {GLTRANS.Transaction.Date} or something similar?

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Unfortunately, I only have 2 datefields to work with. Fiscal Year and Acct_Period.
 
what is acct period? month?

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
are you ok with ugly code? lol
I have a table that has a similar layout (months and year with no date) this is how I would do it but Im a little odd ;)

First I would change your parameter field to a date parameter. That way the user can pick the month from any year.

add this to the selection formula
Code:
year({?date}) = {GLTRANS.FISCAL_YEAR} and month({?date}) = {GLTRANS.ACCT_PERIOD}
or
year(date(year({?date}),month({?date}),1)-1) = {GLTRANS.FISCAL_YEAR} and 
month(date(year({?date}),month({?date}),1)-1) = {GLTRANS.ACCT_PERIOD}
or
year(date(year(date(year({?date}),month({?date}),1)-1),month(date(year({?date}),month({?date}),1)-1),1)-1) = {GLTRANS.FISCAL_YEAR} and 
month(date(year(date(year({?date}),month({?date}),1)-1),month(date(year({?date}),month({?date}),1)-1),1)-1) = {GLTRANS.ACCT_PERIOD}

This is assuming {GLTRANS.ACCT_PERIOD}is a number field. If not you will have to convert it.
I'm quite certain there are cleaner ways to do this and look forward to another reader offering an easier/cleaner approach but this will work:)

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
As long as the code works, I don't care how ugly it is. Both Acct Period and Fiscal Year are number fields.
I've added the code in the selection criteria, but the report returns an error on my select statement.
Says that a "Date Range is required".
How should I change that to get the code to work?
 
show your final formula that is throwing this error

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top