Hi, I need to write a formula for the record selection based on User Parameters. I have created a formula which builds a String which I want to add to an 'in' clause in the Record Selection.
The formula works perfectly if simply used as a field on the report - however as soon as I try to use it in the Record Selection Criteria it tells me that the string is too long. This is not true as the string (and I have tested it using Length) is not over 254 characters.
I also tried using the entire formula in the Record Selection and not having the actual formula on the report but that did not work either - it again told me that the string was too long.
Can someone please tell me what I am doing wrong.
Thanks
Formula to build String...........
BeforeReadingRecords ;
Global stringVar PeriodStr;
stringVar SMonth:= Left ({?FromPer},2);
stringVar SYear:= Right ({?FromPer},2);
stringVar EMonth:= Left ({?ToPer},2);
stringVar EYear:= Right ({?ToPer},2);
stringVar List ;
numberVar i;
numberVar x;
numberVar y;
stringVar yStr;
numberVar z;
stringVar zStr;
if SYear = EYear then
(
for i := CDbl (SMonth) to CDbl (EMonth) do
( y := i;
if y < 10 then
(
yStr := "0" & Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
else
(
yStr := Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
)
)
else
( for x := CDbl (SYear) to CDbl (EYear) do
(z := x;
if z < 10 then
(
zStr := "0" & Left(CStr(z),Length(CStr(z))-3);
SYear := zStr;
z := z + 1
)
else
(
zStr := Left(CStr,Length(CStr)-3);
SYear := zStr;
z := z + 1
);
for i := CDbl (SMonth) to 12 do
( y := i;
if y < 10 then
(
yStr := "0" & Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
else
(
yStr := Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
);
if y > 12 then
(z = z + 1;
if z < 10 then
(
zStr := "0" & Left(CStr(z),Length(CStr(z))-3);
SYear := zStr;
z := z + 1
)
else
(
zStr := Left(CStr,Length(CStr)-3);
SYear := zStr;
z := z + 1
)
);
for i := 1 to CDbl (EMonth) do
( y := i;
if y < 10 then
(
yStr := "0" & Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
else
(
yStr := Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
);
if SMonth = EMonth and SYear = EYear then exit for;
)
);
PeriodStr := TrimRight(Left(List,Length(List)-1));
CStr(TrimRight(Left(List,Length(List)-1)))
Results of formula as printed on report..................
"0601","0701","0801","0901","1001","1101","1201","0102","0202","0302","0402","0502"
In Record Selection Formula Editor I have the following .....................
Global stringVar PeriodStr;
{periodt.pe} in [PeriodStr]
The formula works perfectly if simply used as a field on the report - however as soon as I try to use it in the Record Selection Criteria it tells me that the string is too long. This is not true as the string (and I have tested it using Length) is not over 254 characters.
I also tried using the entire formula in the Record Selection and not having the actual formula on the report but that did not work either - it again told me that the string was too long.
Can someone please tell me what I am doing wrong.
Thanks
Formula to build String...........
BeforeReadingRecords ;
Global stringVar PeriodStr;
stringVar SMonth:= Left ({?FromPer},2);
stringVar SYear:= Right ({?FromPer},2);
stringVar EMonth:= Left ({?ToPer},2);
stringVar EYear:= Right ({?ToPer},2);
stringVar List ;
numberVar i;
numberVar x;
numberVar y;
stringVar yStr;
numberVar z;
stringVar zStr;
if SYear = EYear then
(
for i := CDbl (SMonth) to CDbl (EMonth) do
( y := i;
if y < 10 then
(
yStr := "0" & Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
else
(
yStr := Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
)
)
else
( for x := CDbl (SYear) to CDbl (EYear) do
(z := x;
if z < 10 then
(
zStr := "0" & Left(CStr(z),Length(CStr(z))-3);
SYear := zStr;
z := z + 1
)
else
(
zStr := Left(CStr,Length(CStr)-3);
SYear := zStr;
z := z + 1
);
for i := CDbl (SMonth) to 12 do
( y := i;
if y < 10 then
(
yStr := "0" & Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
else
(
yStr := Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
);
if y > 12 then
(z = z + 1;
if z < 10 then
(
zStr := "0" & Left(CStr(z),Length(CStr(z))-3);
SYear := zStr;
z := z + 1
)
else
(
zStr := Left(CStr,Length(CStr)-3);
SYear := zStr;
z := z + 1
)
);
for i := 1 to CDbl (EMonth) do
( y := i;
if y < 10 then
(
yStr := "0" & Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
else
(
yStr := Left(CStr,Length(CStr)-3);
SMonth := yStr;
List := List & Chr(34) & SMonth & SYear & Chr(34) & "," ;
y := y + 1
)
);
if SMonth = EMonth and SYear = EYear then exit for;
)
);
PeriodStr := TrimRight(Left(List,Length(List)-1));
CStr(TrimRight(Left(List,Length(List)-1)))
Results of formula as printed on report..................
"0601","0701","0801","0901","1001","1101","1201","0102","0202","0302","0402","0502"
In Record Selection Formula Editor I have the following .....................
Global stringVar PeriodStr;
{periodt.pe} in [PeriodStr]