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!

Last name & First initial Only 2

Status
Not open for further replies.

KalebsDad78

Technical User
May 6, 2006
57
0
0
US
Using Crystal XI with an ODBC database:

I have a customers name field that displays full last name, full first name. I only want the customers full last name and the first initial of the first name. I have a working formula to just trim the name -3 characters but for long names, you can still pretty much tell what the name is and for short first names, it cuts into the last name.

The string field is named: customers.name

Any help is appreciated.
 
Assuming the field is Surname first then Christian name, separated by a space, try:

Code:
Split({Customers.Name}, ' ')[1] + ' ' + Split({Customers.Name}, ' ')[2][1]


Cheers
Pete
 
The field is last name, first name.

Using the formula above I get an error that states: " A subscript must be between 1 and the size of the array."

When I click okay, it takes me to the formula and highlights the following section:

Split({Customers.Name}, ' ')[2]
 
The formula is splitting the name field on the space, so that means there is at least one record that does not have a space. Amend the code as follows:

Code:
If      Ubound(Split({Customers.Name}, ' ')) > 1
Then    Split({Customers.Name}, ' ')[1] + ' ' + Split({Customers.Name}, ' ')[2][1]
Else    {Customers.Name}

Cheers
Pete
 
Sorry, I only just realised that your last post indicated that the 2 names are separated by a comma then space (", "). Amend the formula to:

Code:
If      Ubound(Split({Customers.Name}, ', ')) > 1
Then    Split({Customers.Name}, ', ')[1] + ' ' + Split({Customers.Name}, ', ')[2][1]
Else    {Customers.Name}

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top