Click to See Complete Forum and Search --> : [RESOLVED] formula field
bezaman
Feb 10th, 2009, 12:55 PM
i have a formula field. Here is the code:
stringVar array x1 := "";
stringVar result := "";
numberVar i;
numberVar top := ubound(split({tblJobs.scflist},'|'));
for i := 1 to top do
(
redim preserve x1[i];
x1[i] := split({tblJobs.scflist},'|')[i];
result := result + x1[i];
result := result + chr(10);
);
if {tblJobs.choosescf} and result = "" then "Please Advise" else result;
if {tblJobs.scflist} is null then i get no result. it will not process anything after the for loop. how can i get around this?
brucevde
Feb 10th, 2009, 01:38 PM
When a Null field is encountered in a formula Crystal immediately stops evaluating the formula and no result is returned.
Add an If statement and check if the field is null or not.
stringVar array x1 := "";
stringVar result := "";
numberVar i;
numberVar top := 0;
If Not IsNull({tblJobs.scflist}) Then
(
top := ubound(split({tblJobs.scflist},'|'));
for i := 1 to top do
(
redim preserve x1[i];
x1[i] := split({tblJobs.scflist},'|')[i];
result := result + x1[i];
result := result + chr(10);
);
)
if {tblJobs.choosescf} and result = "" then "Please Advise" else result;
bezaman
Feb 10th, 2009, 01:47 PM
ok. thanks for the info.
when i tried the code but i get an error:
The remaining text does not appear to be part of the formula.
and it is on the very last line.
bezaman
Feb 10th, 2009, 02:15 PM
this works.
stringVar array x1 := "";
stringVar result := "";
numberVar i;
numberVar top := 0;
If Not IsNull({tblJobs.scflist}) Then
(
top := ubound(split({tblJobs.scflist},'|'));
for i := 1 to top do
(
redim preserve x1[i];
x1[i] := split({tblJobs.scflist},'|')[i];
result := result + x1[i];
result := result + chr(10);
);
if {tblJobs.choosescf} then "Please Advise" + result else result;
)
else if {tblJobs.choosescf} then "Please Advise"
brucevde
Feb 10th, 2009, 02:32 PM
I think I missed the semi-colon after the after the end bracket of the first If statement.
result := result + chr(10);
);
);
if {tblJobs.choosescf} and result = "" then "Please Advise" else result;
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.