Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9209247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:47:51+00:00 2026-06-18T00:47:51+00:00

The following function returns the A subscript must be between 1 and size of

  • 0

The following function returns the “A subscript must be between 1 and size of array”-error when run in Crystal Reports XI. Any idea why and how to fix it?

Function (optional BooleanVar start := true)

DateVar Array reportdates := [
    cDate(2012, 10, 22),
    cDate(2012, 11, 15),
    cDate(2013, 01, 23),
    cDate(2013, 02, 20),
    // some more lines of dates...
    cDate(2014, 01, 02)
];

// Here is some code that sorts the array just to be sure.
// Removed from question

// Find index of last reportdate not later than today
NumberVar stopIndex;
for i := 1 to UBound(reportdates) do (
    if CurrentDate >= reportdates[i] then
        stopIndex := i
    );

DateTimeVar returnDateTime;
if start = true then (  // return start date
    NumberVar startIndex;
    if stopIndex = 1 then
        startIndex = 1
    else
        startIndex = stopIndex - 1;
//*** The error occurs here
    returnDateTime := cDateTime(reportdates[startIndex], cTime(0,0,0));
//*** The error occurs here
    )
else (  // return stop date
    DateVar stopDate = reportdates[stopIndex];
    returnDateTime := dateAdd("d", -1, cDateTime(reportdates[stopIndex], cTime(23,59,59)));
    );

returnDateTime;

Note:
I found that the above function returns an earlier stop date than start date if run before the second date in the array. I rewrote the function to counter that and then I did not have a situation that produced the error in question, but I would still be interested in why the error occured in this function and how to handle it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:47:53+00:00Added an answer on June 18, 2026 at 12:47 am
    NumberVar startIndex;
    if stopIndex = 1 then
        startIndex = 1
    else
        startIndex = stopIndex - 1;
    

    should of course be

    NumberVar startIndex;
    if stopIndex = 1 then
        startIndex := 1
    else
        startIndex := stopIndex - 1;
    

    and now it works…

    NumberVar stopIndex;
    

    should also be changed to

    NumberVar stopIndex := 1;
    

    to avoid errors if report is run before first report date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following function returns a randomly generated adjacency matrix of size nxn , representing
Assume i have the following function: def select_queryset(value_to_decide_upon): this function returns either any of
I have the following function in a PHP script, which returns and API call:
I'm having a weird problem with the following function, which returns a string with
For the following script, how can I write a function that returns all of
I have written the following function in Java. This function returns current timestamp by
I know that the following function returns the current Windows user's name in domain\username
In C++11 it is possible to create a function which returns the size (number
The following Javascript function returns a JS object: function getCookies() { var result =
I wrote the following function which returns the middle element of a linked list,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.