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

String Manipulation

Status
Not open for further replies.

RuiPedro

Programmer
Jul 17, 2003
2
PT
Sorry! You may say that the question is so simple that I'm taking your time but I'm begginer and I have this problem : I have 1 Access table field with the full name of my costumers and I need to place ONLY the first and the last names in the Crystal Report. How can I do that ? Thanks for your help
 
RuiPedro,

Show us an example of your name field as it currently is in the database, and then show us an example of how you would like the name to be represented in the report.

Thanks,

Naith
 
Thanks Naith for your help.
For example the ful name of my costumer is "Rui Pedro Ribeiro Carvalho" and I want only to be represented in the report the first and the last names like this "Rui Carvalho". By the way that is my full name and I'm from Portugal. Thank you again.
 
Using InStr you can search for the first space. For example:-

InStr("Rui Pedro Ribeiro Carvalho"," ")

This should return the number 4 for the first space. Then you could strip out the characters you don't need by doing something like

StringVar Str;
Str = Left("Rui Pedro Ribeiro Carvalho",4-1)

I only put the 4-1 as a guide to show that it must be the result of InStr - 1.

For the last name, you just need to use InStrRev instead.
 
You could try this:

left({table.name},instr({table.name}, " "))+trim(mid({table.name},instrrev({table.name}, " ")))

Substitute your name field for {table.name}.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top