Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Arrays Post Reply Post New Topic
Author Message
bobbabuoy
Newbie
Newbie


Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
Quote bobbabuoy Replybullet Topic: Arrays
    Posted: 21 Mar 2008 at 4:00am
I am a vb/asp programmer that is trying to learn CR.  I want to declare a 1-dimensional array and assign it values in the selection formula area.  Can someone give me the Crystal Syntax for this?

Thanks~
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 21 Mar 2008 at 2:51pm
Here is a quick sample code that should be enough to get you going.
NumberVar Array X;
ReDim X[2];
X[1]:=1;
X[2]:=55;

I cover arrays and the functions for working with them in Chapter 7 of my Crystal Reports Encyclopedia book. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.

And did you really post this question at 4am??
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
bobbabuoy
Newbie
Newbie


Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
Quote bobbabuoy Replybullet Posted: 22 Mar 2008 at 5:50am
Thanks for the help.  I am new to CR as I said but this looks like a great resource.  I expect to be buying your book. 

Here is my next question:  I have this selection code:

StringVar Array AccntNum;

ReDim AccntNum[11];

AccntNum[1]:="000";
AccntNum[2]:="00";
AccntNum[3]:="01";
AccntNum[4]:="02";
AccntNum[5]:="03";
AccntNum[6]:="04";
AccntNum[7]:="05";
AccntNum[8]:="08";
AccntNum[9]:="11";
AccntNum[10]:="12";
AccntNum[11]:="13";

if {?AccntNum} <> "" then
    {Orders.Account #}={?AccntNum} and {Orders.Use Date} = {?DateRange}
else
  {Orders.Use Date} = {?DateRange}


I want to exclude the account numbers in the AccntNum array from selection.  How can I do that?

IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 22 Mar 2008 at 9:18am
Can you rephrase the question? Are you trying to exclude records that have an acctnum in the array from being printed, or are you trying to redo the if-then statement to make it use the array. Not sure what the exact problem is...
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
bobbabuoy
Newbie
Newbie


Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
Quote bobbabuoy Replybullet Posted: 22 Mar 2008 at 11:03am
I am trying to exclude records from the database that meet a certain criteria (those that have an account number that is included in the array) from being displayed.  
IP IP Logged
bobbabuoy
Newbie
Newbie


Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
Quote bobbabuoy Replybullet Posted: 25 Mar 2008 at 4:06am
Totally rephrasing the question here:

Here is what I have and it works fine but it seems a little too "brute force".  Also, it begs the larger question:  How do I exclude records from the sql query based on their value (as I am doing here with these 11 values) without listing each one out?


if {?AccntNum} <> "" then
    {Orders.Account #}={?AccntNum} and {Orders.Use Date} = {?DateRange}
else
    if {Accounts.Account #} <> "000" and {Accounts.Account #} <> "00" and {Accounts.Account #} <> "01" and {Accounts.Account #} <> "02"
    and {Accounts.Account #} <> "03" and {Accounts.Account #} <> "04" and {Accounts.Account #} <> "05" and {Accounts.Account #} <> "08"
    and {Accounts.Account #} <> "11" and {Accounts.Account #} <> "12" and {Accounts.Account #} <> "13" then
        {Orders.Use Date} = {?DateRange}


Thanks in advance...
IP IP Logged
Urgh
Newbie
Newbie
Avatar

Joined: 24 Mar 2008
Location: United States
Online Status: Offline
Posts: 5
Quote Urgh Replybullet Posted: 25 Mar 2008 at 3:45pm
Use the select expert to select the account number then "not one of" then key in the account numbers you want to exclude.
IP IP Logged
bobbabuoy
Newbie
Newbie


Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
Quote bobbabuoy Replybullet Posted: 25 Mar 2008 at 4:01pm
The problem with that is that I have a "Composite Expression" and I am told, "Please use the formula editing to do editing.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 25 Mar 2008 at 7:23pm
Rather than having CR create the formula, enter it manually using the formula editor. I would replace the else section with something a bit more elegant using the IN operator and an array constant.
....
else
    if NOT ({Accounts.Account#} IN ["000","00","01","02"]) then
       {order.use date} = {?DateRange}

Of course, add all the string tests rather than just the few I copied.

Chapter 7 of my book covers how to use arrays and the functions that work with arrays. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.