Results 1 to 5 of 5

Thread: [RESOLVED] formula field

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    Resolved [RESOLVED] formula field

    i have a formula field. Here is the code:

    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?

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: formula field

    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.

    Code:
    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;

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    Re: formula field

    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.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    779

    Re: formula field

    this works.

    Code:
    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"

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [RESOLVED] formula field

    I think I missed the semi-colon after the after the end bracket of the first If statement.

    Code:
        result := result + chr(10);
      );
    );
    
    if {tblJobs.choosescf} and result = "" then "Please Advise" else result;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width