Aw, c'mon Traci, did you even look at the online help? It's right there, under "Help | ObjectPAL Reference Topics | Index | UIObject | UIObject type | action | ActionDataCommands | DataSaveCrosstab", where it says, 'Writes given crosstab to CROSSTAB.DB.' I mean, with such complete and clearly organized help as this, I don't know why we even need a support forum.
Seriously, it took me sixteen minutes to find this entry -- and I knew it was there. You won't find anything on 'crosstab' under 'save' or 'write', and looking under 'crosstab' itself does no good at all. Trying to find 'savecrosstab' in the help index doesn't work because the index locates only whole words, and the term 'savecrosstab' never appears in the help, just 'datasavecrosstab'. But you probably know all this already.
Well, anyway, to save the contents of your crosstab uiobject, you code
<CrossTab>.forceRefresh()
<CrossTab>.action(DataSaveCrosstab)
which causes Paradox to write the current contents of the crosstab to ':PRIV:CROSSTAB.DB'.
You could then use ':PRIV:CROSSTAB.DB' as the master table in your report.
One problem you should be aware of, when basing a report on a crosstab operation: The number and names of the
columns in a crosstab depends on the
values in the orignal data. The crosstab contains a column for each unique value that appears in the source field selected as the 'Column' value when defining the crosstab. As the data changes, if there are no records in the source data with a particular value, the column for that value will disappear from the crosstab. Any report based on the crosstab will encounter a missing field, and will not open without error.
For example, suppose I have a table:
SRCDATA.DB
Name A20
Class A10
Grade N
And a form with a crosstab bound to this table. The crosstab is defined as Column='Class', Categories='Name', and Summaries='max(Grade)'. Suppose further that I save the crosstab and design a report based on ':PRIV:CROSSTAB.DB'.
With the example data below, the crosstab will contain columns named Lang and Math, and the report will have columns for Lang and Math and will display records for Alice, Bob, and Carol:
SOURCE DATA SAVED CROSSTAB VIEWED REPORT
Name Class Grade Lang Math Name Lang Math
---- ---- ---- ---- ---- ---- ____________________
Alice Lang 2.5 Alice 2.5 3.9
Alice Math 3.9 Bob 2.0 2.9 Alice 2.5 3.9
Bob Lang 2.0 Carol 4.0 Bob 2.0 2.9
Bob Math 2.9 Carol 4.0
Carol Math 4.0
Now suppose that Alice and Bob both drop Lang. Nobody is taking Lang at all. If I run the same program now, the data, crosstab, and report look like this, and viewing the report generates a runtime error:
SOURCE DATA SAVED CROSSTAB VIEWED REPORT
Name Class Grade Math Name Lang Math
---- ---- ---- ---- ---- ____________________
Alice Math 4.0 Alice 4.0
Bob Math 4.0 Bob 4.0 Alice [UNDEFIN] 4.0
Carol Math 4.0 Carol 4.0 Bob [UNDEFIN] 4.0
Carol [UNDEFIN] 4.0
There is no simple solution to this problem. It is part of the nature of cross tabulation.
In the example above, based on students and classes, I would create a dummy student who always took every class in the catalog every semester. This would force all the columns in the catalog to appear in the crosstab. Then I would filter out the dummy student's record before reporting.
The closest thing to a general solution to the missing column problem is to scan the saved crosstab data and copy the records into a prepared empty table that has all the required fields. You would have to use scan and test for the existence of each field, because QBE or table copy will also choke on the missing column.
This probably seems like much more than you want to know about crosstabulation right now, but save this answer in your notes in case you want to come back to it.
-Al.