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

First Name Last Name formula

Status
Not open for further replies.

BROWNIE56

Programmer
Dec 28, 2000
31
US
In our software program we have the client enter their name like the following:

Brown, Sharon

That is how it is stored in the table.

I have one report I need to write but I need the names to display as First Name then Last Name.

I was given the following formula to use but it does not seem to work. Any suggestions?

WhilePrintingRecords();
NumberVar nPlace;
StringVar szFirstHalf;
StringVar szSecondHalf;

InStr({PATIENT.pat_name}, ",");
if(nPlace <> 0)
then szFirstHalf := Left({PATIENT.pat_name}, nPlace-1);
if(nPlace <> 0)
then szSecondHalf := Right({PATIENT.pat_name}, (Length({PATIENT.pat_name})-nPlace));
if(nPlace <> 0)
then szFirstHalf+szSecondHalf
else {PATIENT.pat_name};
 
I know that there is a way to do it, but you'll want to try getting a hold of Crystal yourself. There is a function available for Crystal 8 that is not included with the basic package. They'll send you the .dll's that you need. I can't think of what they are off hand (I used them with a previous employer), but they might be able to give you an answer if you explain your problem. Good luck!
 
Thank you. But, we have to stay with Crystal 5. Crystal 8 runs are reports way to slow.
 
Your formula doesn't define a value for the variable nPlace.
Try
WhilePrintingRecords();
NumberVar nPlace;
StringVar szFirstHalf;
StringVar szSecondHalf;
[red]nPlace :=[/red] InStr({PATIENT.pat_name}, &quot;,&quot;);
if(nPlace <> 0) [red]etc[/red]
Malcolm Wynden
I'm for sale at malcolm@wynden.net
 
how do i put last name first and then first name seperated by a comma into one field from to seperate fields
 
I'll assume that mid doesn't work in CR 5 here.


This formula should suffice (You shouldn't require variables to accomplish):

If instr({PATIENT.pat_name}, &quot;,&quot;) > 0 then
Right({PATIENT.pat_name}, (Length({PATIENT.pat_name})- InStr({PATIENT.pat_name}, &quot;,&quot;)))
+&quot;, &quot;+
left({PATIENT.pat_name}, instr({PATIENT.pat_name}, &quot;,&quot;)-1)
else // In case there isn't a comma
{PATIENT.pat_name}

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top