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!

Global Data - How to Use

Status
Not open for further replies.

MikeCopeland

Programmer
May 21, 2007
91
US
Using CRXI...
How does one use global data? How is it accessed and used in a report? For example, I've written a small function:
// @testGlobal - root test of global variable MRCopeland
Global NumberVar p17;
p17 := -17

It has no errors, but what does it actually _do_ insofar as manipulating "p17", and how do I use that data? I can't see how to access "p17".
The reason I'm exploring this feature (and it may be the wrong approach...) is that I need to do several things in a function (make a test, produce/modify several pieces of data, have those variables available in subtoal and total lines), and I don't know how to do such things. AFAIK, a function returns only one type of data value, and its return value is accessed placing that function on the report (or in another function or group formula). However, since the formula syntax allows compound statements, I assume (and hope!) that I can have a formula do multiple things (produce an object, increment totals, etc.).
Am I wrong in this? If so (or not), how do I accomplish comllex actions in CR? TIA
 
In Crystal, you don't have direct control of the variables. It's not a full programming language and you have to accept that some things aren't possible in it.

Usually you access a variable using a formula field, as you have. Normal variable are fine within a report, while shared variables can pass data back from a subreport to the main report. I've never found it necessary to use global variables.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Variables are global by default, so most people don't specify them. You can read about variables in the help section. I didn't respond to this because you are asking for a training in variables, which is beyond the scope of this forum. If you ask for help with specific problems where you think that variables are the only way to go, I think you would get more targeted responses.

-LB
 
I didn't think my query was outside the scope of the forum - perhaps my mistake was putting the "How to Use" in the Subject. I apologize....
Even so, I don't know what to do here. I have a requirement to produce totals from a SQL database that has 30 different values - I must count the occurences of each value type. Here's the table (T1):
T1.Seq T1.Code T1.Description
1 01 Caucasian
2 02 African-American
3 03 Hispanic
4 04 Asian
5 05 Native American
6 CH AK Chin
7 CO Cocopah
8 CR Crit
9 FM Fort Mohave
10 GR Gila River
11 HA Havasupai
12 HO Hopi
13 HU Hunlapal
14 KP Kaibab Palute
15 MY Fort McDowell
16 NA Navajo Nation
17 PY Pascua Yaqui
18 QU Quechan
19 SC San Carlos Apache
20 SR Salt River Pima
21 TA Tonto Apache
22 TO Tohono O'Odham
23 WM White Mountain
24 YA Camp Verde
25 YP Yavapa Prescott
26 06 Multi-Racial
27 07 Pacific Islander
28 08 Unknown
29 09 Other
30 Blank
The database that links to this table has a field (T1.Race) that has the values shown here as T1.Code. For every record in T1, I want to count the distinct T1.Race values (# of Caucasian clients, # Multi-Racial clients, etc.)...and I don't know how I can do this in CR. I had thought I could do the counting in a formula, by using an array, but I don't know how to access that array data in my suntotal and total lines.
This _seems_ like the sort of thing CR should be able to do, but I can't seem to "find the pieces" that will help me get it done. Please advise.
 
You are showing what looks like a lookup table. If you link your table that has the race field, by linking {table.race} to {T1.code}, then you should be able to insert a crosstab that uses {T1.description} as the row field, and count of {table.race} as the summary field. It does look like the lookup also has a subcategory to break out Native American--does the data table have another field that might relate to that?

-LB
 
<arrrrgh...> My mistake again... I included the table only to show the magnitude of my problem: that I have some 30 different total (subtotal, grand total) combinations to deal with. I was hoping that there was some sort of "global array" processing that would let me accumulate counts of each (racial) client type, as well as display them in various subtotal/total lines in a simple and consistent manner.
I have been doing with with individual sums, group totals, and line formating, and it's very tedious programming and layout. 8<{{
Insofar as the table's category of "Native American" goes, I have no control over that: the client records are what they are, as inputted by therapists from whatever documents they have. So far, I've actually seen only 8 different racial combinations, but I nonetheless have to program for all possibilities (i.e. the table I show above).
Maybe there's no "easy" way to do all this, but because of my limited (volunteer) time I spend on this project, I was hoping for some way to "shortcut" the development of these reports. <sigh>
 
You have not clarified the situation--I can't tell what the problem is. I work with multiple ethnicity fields and have come up with a way to show various combinations of ethnicities (for people who identify more than one) using variables, and maybe I could help, but I don't know what your race field is in the one table (what it displays), or how it relates to your lookup table. Why don't you show some sample data and show/explain the end result you want to achieve.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top