CherrySoda
Technical User
Crystal v.10 connecting to an Interbase (ODBC) database.
I am creating a report that uses the following fields in the detail section
Job# Date StartTime Category Hours
1 1/5/08 8:00am A 1
2 1/5/08 9:00am B 1
3 1/5/08 10:00am 1
4 1/5/08 11:00am A 1
5 1/5/08 12:00pm A 1
6 1/5/08 1:00pm 1
and so on for with multiple records for many other dates
This report is sorted by StartTime and I want to group first by date, and then by Category. Since some records have no category value, I want that value to be assigned the same category value as the previous entry, so the Category value for Job# 3 is B and the value for Job# 6 is A.
I have been trying to get this to work by creating a formula field, and using a global variable that stores that current Category value, and if the category field is null, then the currently stored value (that of the previosu record) is used. The end result is below:
Job# Date StartTime Category Hours FormulaField
1 1/5/08 8:00am A 1 A
2 1/5/08 9:00am B 1 B
3 1/5/08 10:00am 1 B
4 1/5/08 11:00am A 1 A
5 1/5/08 12:00pm A 1 A
6 1/5/08 1:00pm 1 A
I am having difficulty in writing the proper code for the formula, so that I can then group by that field.
//Begin Code
global stringvar JOBCAT
whileprintintrecords;
JOBCAT;
if (isnull({Job.Category})) or ({Job.Category} = "") then
JOBCAT
else if not isnull({Job.Category}) then
JOBCAT := {Job.Category}
else JOBCAT := "ERROR"
//End Code
This formula works, but when I then try to group by Date and the the FormulaField, something happens and the FormulaField no longer replaces the null values with the previous record's value. How can I fix this formula to allow me to then group by it? Or should I try something different?
I am creating a report that uses the following fields in the detail section
Job# Date StartTime Category Hours
1 1/5/08 8:00am A 1
2 1/5/08 9:00am B 1
3 1/5/08 10:00am 1
4 1/5/08 11:00am A 1
5 1/5/08 12:00pm A 1
6 1/5/08 1:00pm 1
and so on for with multiple records for many other dates
This report is sorted by StartTime and I want to group first by date, and then by Category. Since some records have no category value, I want that value to be assigned the same category value as the previous entry, so the Category value for Job# 3 is B and the value for Job# 6 is A.
I have been trying to get this to work by creating a formula field, and using a global variable that stores that current Category value, and if the category field is null, then the currently stored value (that of the previosu record) is used. The end result is below:
Job# Date StartTime Category Hours FormulaField
1 1/5/08 8:00am A 1 A
2 1/5/08 9:00am B 1 B
3 1/5/08 10:00am 1 B
4 1/5/08 11:00am A 1 A
5 1/5/08 12:00pm A 1 A
6 1/5/08 1:00pm 1 A
I am having difficulty in writing the proper code for the formula, so that I can then group by that field.
//Begin Code
global stringvar JOBCAT
whileprintintrecords;
JOBCAT;
if (isnull({Job.Category})) or ({Job.Category} = "") then
JOBCAT
else if not isnull({Job.Category}) then
JOBCAT := {Job.Category}
else JOBCAT := "ERROR"
//End Code
This formula works, but when I then try to group by Date and the the FormulaField, something happens and the FormulaField no longer replaces the null values with the previous record's value. How can I fix this formula to allow me to then group by it? Or should I try something different?