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

Create name by extract from field

Status
Not open for further replies.

UHsoccer

Programmer
Apr 24, 2003
139
US
I have to create a consistent set of names for display using V8.5

Here are a sample of what the data base has and what I need to display

Data base content -> Display on report

Smith, Joe -> Smith, Joe
Smith-ROME, Joe -> Smith, Joe
Smith-Eastern, Joe -> Smith, Joe

What is the syntax
 
For the limited sample, try:

left({table.field},instr({table.field},"-")-1)+", "+
trim(mid({table.field},instr({table.field},",")+1))

-k
 
I think you would need to add a clause to that to allow for non-hyphenated names:

if instr({table.field},"-") > 0 then
left({table.field},instr({table.field},"-")-1)+", "+
trim(mid({table.field},instr({table.field},",")+1)) else
{table.field}

-LB
 
Thanks for the reponse, I just realize that the field name is really just

Smith Smith
Smith-ROME Smith
Smith-Eastern Smith

To I need the extract "up to" the "-" unless there is no "-"

Sorry for the errant innitial post
 
Try:

if instr({table.field},"-") > 0 then
left({table.field},instr({table.field},"-")-1) else
{table.field}

-LB
 
You might want to analyze how these formulas are working as your latest example simply omits part of the existing formula.

It's relatively easy to grasp what it's doing if you spend a few moments on it.

Another means is:

split({table.field},"-")[1]

-k
 
Thanks for the help, it answered my question and several more
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top