Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Name Structure problem Post Reply Post New Topic
Author Message
Krazy Kasper
Newbie
Newbie
Avatar

Joined: 11 Jul 2007
Location: United States
Online Status: Offline
Posts: 23
Quote Krazy Kasper Replybullet Topic: Name Structure problem
     Posted: 27 Jan 2009 at 5:48am
 
My ODBC table has one field for name.
The structure is lastname, firstname middleintital.
There is not always a middleinitial.

The code I'm using (follows) only gives me the middleinitial:

local StringVar Array Names1:=
Split({OptimizeIt.OrderRepName}, " ");
If UBound(Names1)=3 Then ProperCase(Names1[3]) Else " "


Changing it to the following only gives me the firstname:

local StringVar Array Names1:=
Split({OptimizeIt.OrderRepName}, " ");
If UBound(Names1)=2 Then ProperCase(Names1[2]) Else " "

Changing it to the following gives me nothing:
(You'd think it would give me the lastname):

local StringVar Array Names1:=
Split({OptimizeIt.OrderRepName}, " ");
If UBound(Names1)=1 Then ProperCase(Names1[1]) Else " "

Can someone help me put this all together so I get firstname middleinitial lastname (and no comma)?
Thanks.



Edited by Krazy Kasper - 27 Jan 2009 at 5:48am
Krazy Kasper
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 27 Jan 2009 at 6:34am
For your last name, your if statement is what is causing it to be blank, at least in your test...There are always 2 names, so the ubound returns 2, which is not equal to 1, so a blank is returned.
 
Would something like this work:
switch(
ubound(names1) = 1, ProperCase(Names1[1]) ,
ubound(names1) =2, ProperCase(Names1[2]) + " " + ProperCase(Names1[1]) ,
ubound(names1) = 3, ProperCase(Names1[2]) + " " + ProperCase(Names1[3]) + " " +  ProperCase(Names1[1])
)
 
Hope this helps
IP IP Logged
Krazy Kasper
Newbie
Newbie
Avatar

Joined: 11 Jul 2007
Location: United States
Online Status: Offline
Posts: 23
Quote Krazy Kasper Replybullet Posted: 27 Jan 2009 at 8:19am
Thanks. I'll give it a shot.
Krazy Kasper
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum