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

Pulling list of numbers some with an ext and some without 1

Status
Not open for further replies.

rollypac

Programmer
Jun 13, 2003
23
0
0
US
In a subreport, I am pulling in a list of workphone, workphone ext. cell, pager and fax numbers, in that order.

if {MEMBER.WORK_PHONE} <> &quot;( ) -&quot;
then numbers := numbers + &quot;Work Phone &quot; + [member.work_phone};

If I pull in the work phone ext

if {MEMBER.EXT}<> &quot;&quot;
then numbers := numbers + &quot; Ext &quot; + {MEMBER.EXT};

and there is no ext the rest of the numbers don't print for that record.
Any ideas?
 
It sounds like you have 2 fields to construct a phone number ext, and want to display multiples in one line?

whileprintingrecords;
shared stringvar numbers;
If {MEMBER.WORK_PHONE} <> &quot;( ) -&quot; then
numbers := numbers + &quot;Work Phone &quot; + [member.work_phone};
if {MEMBER.EXT}<> &quot;&quot;
then numbers := numbers + &quot; Ext &quot; + {MEMBER.EXT};

You didn't describe where these are being displayed (passed back to the main report, or?), all that this formula does is concatenate numbers.

This would concatenate the numbers into 1 variable, which could be displayed later, say at the perons group footer level.

Consider posting example data and expected output, rather than text descriptions, and if you want specific help, include versioning info for Crystal and the database.

-k
 
I have what you have but I also need to add cell, pager and fax numbers to the variable to print in the group footer.
If {MEMBER.WORK_PHONE} <> &quot;( ) -&quot; then
numbers := numbers + &quot;Work Phone &quot; + [member.work_phone};
if {MEMBER.EXT}<> &quot;&quot;
then numbers := numbers + &quot; Ext &quot; + {MEMBER.EXT};
if {MEMBER.CELLULAR} <> &quot;( ) -&quot; then
numbers := numbers + &quot; Cellular &quot; + {MEMBER.CELLULAR};

The problem occurs when the ext is blank. It doesn't pull the cell, pager and fax numbers into the variable.
 
Ahhh, I see

Test each condition with an isnull(), as in:

If {MEMBER.WORK_PHONE} <> &quot;( ) -&quot;
and
not(isnull({MEMBER.WORK_PHONE})) then
numbers := numbers + &quot;Work Phone &quot; + [member.work_phone};
if {MEMBER.EXT}<> &quot;&quot;
and
not(isnull({MEMBER.EXT})) then
then numbers := numbers + &quot; Ext &quot; + {MEMBER.EXT};
etc...

-k
 
Thanks, that did the trick. I had to put the not (isnull) portion before the <>&quot;&quot; to get it to work.
 
Is the Ext blank or null? You may need to add a null check to the beginning of your forula. I would also consider using variable to hold each number and then concatenate the variables.

whileprintingrecords;
stringvar ext:=&quot;&quot;;
stringvar work:=&quot;&quot;;
stringvar cphone:=&quot;&quot;;
shared stringvar numbers:=&quot;&quot;;

if not(isnull({MEMBER.EXT}) then ext:=&quot; Ext &quot; + {MEMBER.EXT};
If {MEMBER.WORK_PHONE} <> &quot;( ) -&quot; then
work := &quot;Work Phone &quot; + [member.work_phone};
then numbers := numbers + &quot; Ext &quot; + {MEMBER.EXT};
if {MEMBER.CELLULAR} <> &quot;( ) -&quot; then
cphone:= &quot; Cellular &quot; + {MEMBER.CELLULAR};
numbers:=work + ext + cellular


Here's another option. If you want to display your result vertically instead of one long formula. You can use multiple sections to display your numbers. You'll need to create a formula for each number.

Go to Insert/ Section... Choose the section you want to add additional sections to and click the Insert button. - The other method is to right click on the section name (in the grey area) and choose &quot;Insert section below&quot;.

Place each of your formula its own section. Next set up a conditional suppression for each section to suppress when the formula returns a &quot;&quot; value.







Mike
 
Sorry, forgot about the isnull() having to be first in formulas, guess I was rushing things.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top