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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array/Loop Question 1

Status
Not open for further replies.

dstalls

Programmer
Sep 27, 2007
18
US
I am using Crystal XI.

I have a report pulling contact dates into the main report from a subreport. In the main report, I wish to evaluate the contact date(s) to see if they are within a service authorization range. If they are in the range then will be assigned hours to determine a workload.

Usually, there is only one contact date for evaluation. However, sometimes there are more. I would like to evaluate each contact date independently against the range to determine if hours should be assigned. Currently, only the latest date is evaluated.

I assume a loop needs to be done but I am at a loss for how to begin. Any suggestions would be appreciated.




 
Please explain the location of the sub in the main report--what report section, and how it is linked to the main report--on what field(s). Also show the content of the formula you are using in the subreport to set the date to a shared variable, and also show the content of the formula in the main report where you are doing the comparison, and tell us in what section it is located.

It would also help to a sample of what is returned to the main report by the sub.

-LB
 
Thanks lbass (you have helped a few time before :)),

Q. Please explain the location of the sub in the main report--what report section, and how it is linked to the main report--on what field(s).

A. The subreport is in Group Header #5a (Group 1 is Unit, Group 2 is Worker, Group 3 is Case ID, Group 4 is Client ID, Group 5 is Client Service Begin Date, Group 6 is Service Type, & Group 7 is Contact Date).

The subreport is linked to the main report by the following:
{TCAS_CNTAC.CNTAC_DT}>= {?Pm-@startdate} and
{TCAS_CNTAC.CNTAC_DT} <= {?Pm-@enddate} and
{TCAS_CNTAC.CAS_ID} = {?Pm-TCASE.CAS_ID} and
{TSTF_PERS.STF_SSN_NBR} = {?Pm-TSTF_PERS.STF_SSN_NBR}

Q. Also show the content of the formula you are using in the subreport to set the date to a shared variable, and also show the content of the formula in the main report where you are doing the comparison, and tell us in what section it is located.

A. The formula in the subreport that sets the date to a shared variables is:

whileprintingrecords;
shared datetimevar ccfcvar;
if not isnull({TCAS_CNTAC.CNTAC_DT}) then ccfcvar := {TCAS_CNTAC.CNTAC_DT};

I am displaying this variable in the following formula on Group Header #5a:
whileprintingrecords;
shared datetimevar ccfcvar;

I am then creating another variable in Group Footer #5 to change this info into a stringvar:
CStr({@displayccfcvar})

and using the following array on the Group Footer #5:
shared stringVar array MainContactArray;
shared numberVar MainContactCounter2;
if not({@cdarrayinfo} in MainContactArray) then
(MainContactCounter2 := MainContactCounter2 + 1;
if MainContactCounter2 <= 1000
then (Redim Preserve MainContactArray[MainContactCounter2];
MainContactArray[MainContactCounter2] := {@cdarrayinfo}));

Note: I was hoping to then use Join, but I get an error message that the data is not a string (don't know if that would help me get to where I want to go anyway).

Q. It would also help to a sample of what is returned to the main report by the sub.

A. The subreport simply lists dates (i.e., 6/2/2008, 6/19/2008) for one example.

I will not be able to retun to this thread until 7/25/2008 8 am MST.

Thanks again for helping!
 
1- I don't know the content of {@cdarrayinfo}.

2-I don't see how you could be returning more than one date with your shared variable. Or is that the problem?

3-You are trying to collect something into the array, but what? Are these the subreport dates? Are you doing this in an attempt to capture more than one date?

4-I see no comparison of the dates anywhere.

If the issue is you are only sharing one date from the sub, then in the sub, add a formula to the detail section like this:

whileprintingrecords;
shared stringvar x;
if not isnull({TCAS_CNTAC.CNTAC_DT}) then
x := x + {TCAS_CNTAC.CNTAC_DT} + "^";

In the subreport footer, add this formula:
whileprintingrecords;
shared stringvar x;

Then in the main report, you can break out the dates by using formulas like this:

//{@1stDate}:
whileprintingrecords;
shared stringvar x;
stringvar array y := split(x,"^");
if ubound(y) >= 1 then
y[1]

//{@2ndDate}:
whileprintingrecords;
shared stringvar x;
stringvar array y := split(x,"^");
if ubound(y) >= 2 then
y[2]

In the main report you should also have a reset formula in GF5b:

whileprintingrecords;
shared stringvar x := "";

-LB
 
This seems to be working lbass (except my report keeps crashing) so I may need to get back to you on this. I'll report back either way.

Thanks! You are "the master"!!

 
lbass-

What if I want the final value (on my main report) to be a datevar instead of a stringvar?

I tried to just covert via CDate, but this isn't working.

I need to be able to evaluate the date to see if it is in a specific date range.

Thanks!
 
I forgot to convert the datetime in the first formula. I guess you modified it? Try formatting it like this:

whileprintingrecords;
shared stringvar x;
if not isnull({TCAS_CNTAC.CNTAC_DT}) then
x := x + totext({TCAS_CNTAC.CNTAC_DT},"yyyy-MM-dd") + "^";

Then change the display formulas to:

//{@2ndDate}:
whileprintingrecords;
shared stringvar x;
stringvar array y := split(x,"^");
if ubound(y) >= 2 then
cdate(y[2])

-LB
 
Excellent, that did it!! Thanks again lbass.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top