Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
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?
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
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>
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
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>
Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
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.
Joined: 10 Mar 2008
Location: United States
Online Status: Offline
Posts: 37
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}
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
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>
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