mjmiller24
Programmer
I have a phone number extension that, sometimes, has a leading zero(s). Sometimes the field is null, sometimes the leading zero(s) is missing, and sometimes it is formatted properly. I have attempted to write a if/else if/else statement.
I only inculded a snippet of code where I numbered the lines. I keep getting the error that a string is required, at line 11, where the Else if statement is.
At some point the formula editor said there were no errors, but then the phone number extension would only give me spaces and zeros for entries when I browsed the results.
I think part of the problem is that I am not familiar with the syntax I am supposed to use in Crystal Reports.
Any help would be appreciated.
1: Local StringVar ext;
2: Local NumberVar extLen;
3: Local NumberVar i;
4:
5: extLen := Length({MAIN.TELEPHONE_EXTENSION});
6:
7: If IsNull({MAIN.TELEPHONE_EXTENSION}) Then
8: (
9: ext := "";
10: )
11: Else If ( not Isnull({MAIN.TELEPHONE_EXTENSION}) and (extLen < 4) Then
12: (
13: for i:= extLen to 3 do
14: ext := "0" & ext;
15: )
16: Else
17: (
18: ext = {MAIN.TELEPHONE_EXTENSION};
19: );
20: ext
I only inculded a snippet of code where I numbered the lines. I keep getting the error that a string is required, at line 11, where the Else if statement is.
At some point the formula editor said there were no errors, but then the phone number extension would only give me spaces and zeros for entries when I browsed the results.
I think part of the problem is that I am not familiar with the syntax I am supposed to use in Crystal Reports.
Any help would be appreciated.
1: Local StringVar ext;
2: Local NumberVar extLen;
3: Local NumberVar i;
4:
5: extLen := Length({MAIN.TELEPHONE_EXTENSION});
6:
7: If IsNull({MAIN.TELEPHONE_EXTENSION}) Then
8: (
9: ext := "";
10: )
11: Else If ( not Isnull({MAIN.TELEPHONE_EXTENSION}) and (extLen < 4) Then
12: (
13: for i:= extLen to 3 do
14: ext := "0" & ext;
15: )
16: Else
17: (
18: ext = {MAIN.TELEPHONE_EXTENSION};
19: );
20: ext