Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combining firstname and lastname field, how do you do it
Message
 
To
17/05/1999 23:20:47
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00219772
Message ID:
00220080
Views:
28
Just my two cents:

By doing things this way, you lose a level of detail of data. There are also potential problems where you would confuse what is a last name and what is something else (eg. Marcus Welby, MD).

Indexing will also not be nice in some cases. If someone enters John Van Hammond, is Van a middle name or part of the last name?

Joe


>>How does everyone else manage the firstname and lastname fields in a database?
>>
>>Do you create a third field called name which is updated by an update trigger?
>>
>>person.lastname = "Delay"
>>person.firstname = "Evan"
>>person.name = "Delay, Evan" (trigger fills in??)
>>
>>I find that I am constantly combining the first and last name together to present to the user or for indexes..etc..
>>
>>Or do you use a function or a class...?
>
>Hi Evan,
>
>Not really an answer, but in my last few apps I've used a single field for names. I agonized over this for a while, but looking at my development history I couldn't find any cases where keeping the name broken up was of significant value. Having only one field makes a lot of these types of problems go away.
>
>In the validation code of the textbox (etc.) I put in code that basically looks for a comma. If it's there, it assumes the user knows what they're doing (e.g. De Souza, Jesus). If not, it switches words around and puts in the comma. It also doesn't attempt to "comma-ize" single names (e.g. Cher).
>
>* CHEKNAME.PRG
>* (c) 1998, M3 Enterprises Inc. All rights reserved.
>* Decides if a passed name needs to be rearranged (reversed)
>* using the Rev_Name() function.
>* This application wants names in the format
>* Surname, First M.
>* CHEKNAME returns .F. if the passed name is
>* not in that format.
>*
>* 98.03.25 - Al Doman
>* First Version
>* 98.03.31 - Al Doman
>* Changed to simply check if the passed name is OK.
>* Reversing function moved to Rev_Name().
>
>LPARAMETERS tcName
>
>tcName = ALLTRIM(tcName)
>
>* The name is OK if:
>* It is empty, or
>* There already is a comma in the name, or
>* There is NOT a space in the name. This final condition
>* means there is only 1 word in the name (e.g. Cher)
>* which is OK.
>
>* The final (no space) condition makes the EMPTY()
>* condition redundant:
>* RETURN EMPTY(tcName) OR "," $ tcName OR NOT " " $ tcName
>
>RETURN (("," $ tcName) OR (NOT " " $ tcName))
>
>
>* REV_NAME.PRG
>* (c) 1998, M3 Enterprises Inc. All rights reserved.
>* In a name containing 2 or more words, makes the last word
>* the first, following it with a comma, then appending
>* the other word(s) in the original order.
>* Used to change Alan M. Doman to Doman, Alan M.
>* 98.03.31 - Al Doman
>* First Version
>
>* NOTE this function is called only when it has been
>* determined already by CHEKNAME() that the name needs
>* to be reversed.
>
>LPARAMETERS tcName
>
>LOCAL lnLastSpace, lcSurName, lcOtherNames
>
>tcName = ALLTRIM(tcName)
>
>* If there is more than 1 word, and no comma,
>* we're going to assume the last word is the surname.
>lnLastSpace = RAT(" ", tcName)
>
>lcSurName = SUBSTR(tcName, ;
> lnLastSpace + 1, ;
> LEN(tcName) - lnLastSpace)
>
>lcOtherNames = SUBSTR(tcName, 1, lnLastSpace - 1)
>
>RETURN lcSurName + ", " + lcOtherNames
Joseph C. Kempel
Systems Analyst/Programmer
JNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform