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

Combining several fields 1

Status
Not open for further replies.

anet

Programmer
Jul 10, 2001
35
CA
I am working with VB6, CR 4.6 and an Access Database. I have a customer table with the fields:
LastName
FirstName
CompanyName

There will never be both a LastName and CompanyName entered, so when I pull up my customer report I want to have one field on the report called customer and fill it with either a concatenated LastName, FirstName or the CompanyName, whichever is applicable.

Can this be done? If so, how? Thanks.
 
Here is a formula:

This may look overly complicated, but it accounts for a null in either the First or Last Name which, if concatenated without handling will return a null for the entire formula.


//begin @customer
Stringvar FName := If isnull({Table.Fname}) then "" else {Table.Fname} ;
Stringvar LName := If isnull({Table.Lname}) then "" else {Table.Fname} + ", ";
StringVar Co : If isnull({Table.CO}) then "" else {Table.CO};

If CO = "" then (LName + FName) else CO
//end

Of course, the fastest performance would be gained by doing this in your database itself and then just pulling the value into Crystal.

Hope this helps,
ro




Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top