Getting a Record from a String First Name + Family Name

I have a ComboBox, filled on Open, who holds things like:

Monsieur Jean Dupont

and that works fine. The syntax is Monsieur | Mademoiselle | Madame + First Name(s) + Last Name(s).

Excepted when there is more words like: Monsieur Manuel Sanchez Dos Santos de la Vega …

I extract (using NthField) the first name and last name to get data from this guy/gal from a sqlite data base.

The family name is the lastfield (once more, subject to bug): I take the last entry (NthField, with spacce and the # of fields in the “full name”).

What I think I have to do is to choose from the first name field data base that holds Manuel (from the above example) and the last entry (Vega from the above example) from the Name data base field.

After a long quest, I failed to reach a solution.

Ideas ?

My idea was to get a Record whose first name Cell have the second field from my ComboBox,same with the last field from my ComboBox (and prey there are no similar contents (like: Monsieur Manuel Sanchez Dos Santos de la Vega and Monsieur Manuel Sanchez Santos Vega for examples).

PS: for me, the question is clear, but if not for you, simply ask.

When you populate the comobox also put the information into separate arrays or a class or a-n-other method (title,firstname,lastname), you can then access the separated information without having to manipulate strings.

or store the id of the record with the entry of the combobox and look it up again when you need it.

Emile, I don’t understand what you are trying to do.

Here in Mexico usually we have 2 last names, one from the father and one from the mother, so Is common to see something like: Manuel Eduardo Snchez Gonzlez and usually that person is identified as Seor Manuel Snchez.

Things become interesting when you have a last name as ‘Dos Santos de la Vega’, ‘De la Garza’ or ‘Nio de Rivera’.

There is also some tradition that the married woman take the husband last name in this form:
Wife: Sofia Garza Martnez
Husband: Juan Gonzlez Gutirrez
so married wife becomes: Sofia Garza de Gonzlez. Now imagine if the husband’s last name is ‘De la Garza’, the wife becomes Sofia Garza de De la Garza.
*Note: now the official documents in Mxico need to use the same name as birth certificate. My wife had to change back her name on the last passport renewal.

In your example: Manuel Snchez Dos Santos de la Vega, at least in Mexico, it could be:

  • name: Manuel
  • first last name (father’s): ‘Snchez’ or ‘Snchez Dos Santos’
  • second last name (mother’s), ‘Dos Santos de la Vega’ or ‘de la Vega’
    so trying to use only ‘Vega’ in your example is strange for me.

I guess it all depends in what you are trying to do and how your information is in the database. If you only have 1 column for name(s) and 1 for last name(s), it will be hard to know exactly if the last name your looking for is only 1 word or more if the data show 2 or more words.

*Note: there are some changes in Mxico, I think the parents can decide now if the first last name is going to be the father’s or the mother’s (for their children).

In Qubec, parents can choose which last name to give their child: mother’s last name, father’s last name or both with a hyphen in between. On the next generation, only one portion of the composed last name can be used to compose the next generation’s last name, so last names dont grow geometrically. That said, composed names such as Dos Santos, for example, count as one portion. Using nth field would fail.

The safest way is to allow the user to enter the first name portion of their name in a field and the last name portion of their name in a second field, with additional fields for salutation (Mr., Dr., etc.) and for suffixes (Jr., Sr., Third etc.)

It is never safe to use such strings to identify records. Any slight change will result in either a failed query or a wrong query.

The OP’s concern seems to be related to reading some external list and converting it to organized data in a database. I feel that this task is almost impossible to automate. A human needs to do the data cleansing first.

If the question is whether to enter only part of the name in the fields, then the answer is no. The complete information needs to be entered. Perhaps for some regions, a “usual name” field can be added.

To add to the confusion… if the person is of Asian descent… they may specifiy (and desire) Surname FIRST, and in some countries it might be SURNAME last, but you won’t really be able to tell.
And in other countries, they may use TWO (or more) FIRST NAMES
for example (even though I am American)… for legal purposes I use “R. David S” for almost everything. with “R” being the first letter of my first name… the point being you cannot assume the first word is the first name, and the last word is the last name

This was a situation I came across designing a massive database system for a major healthcare company.

What was the question? :smiley:

my interpetation

a task, that given locale, customs, and personal preferences is not even close to being a simple task

+1 Dave.

My mother has 3 first names and the third is made with 3 words, so you can imagine that she can’t use her full name on most forms because there is no space to put that many words :slight_smile:

Thank you all. Very good answers, a bit of fun (appreciated), and yes, I understand.

I too have 3 first names, but I only use the first.

And here too, some people use First Name - Family Name or the reverse order (Family Name - First Name) :frowning:

Back to the question:

Is it possible to get a Record asking for part of the First Name Field ?

Something like getting R. Dave if I ask for Dave ?

PS: Julian advice seems nice: I populate the ComboBox (CB) from the DataBase and I will use the CB to populate a part of the window. So, at CB build time I have the information to get a specific Record.

Here, the night is old, so I will investigate that idea tomorrow morning.

By pure hazard, this bug (of mine) appears in the first Row of that ComboBox and I was searching around 1-0 based, then I was a bit lost until I realized that I have another “long” entry, tried it and found the bug. I was looking South when I could (must ?) look everywhere. Bad to reach a solution. :frowning:

Combobox has rowtag getter/setter methods, so populate it with the primary key of the record or an ORM object that represents the record from the database.

If you are using SQL, then yes

SELECT firstname FROM myTABLE where firstname LIKE "%Dave%"

I’ve been through this problem several times over the years when I used to develop databases for clients, and then try to import their badly formatted data. The import process can be partially automated using various programming tricks, but there still remains a large chunk that needs human review.

So, if you’re developing a new database application, you have to decide if one field containing full name and title is sufficiently granular (i.e., you won’t ever need to extract a first or last name or title from it). If not, then the only solution is to have separate entry fields for Title, First Name and Last Name.

Thanks Robert, Dave.

Dave: I was near the solution. I only missed the ending % character !

And now that I read that, this looks (to by oldster memory) like I already use that in another project.

Thanks again Dave.

Note to self: Why do I stopped to fill my list of Tricks project ?

Edit: I already visited the page
https://www.w3schools.com/sql/sql_like.asp !!!

What is infuriating is… the command works fine if there is only 3 “fields“ in the ComboBox entry (Monsieur Jean Dupont) :frowning:

OK: the RowTag trick is the winner. For whatever reason, I was not able to make LIKE trick working :frowning:

THANK YOU ALL.

For the Record (and as suggested), at ComboBox.Open time, I add this line, after Me.AddRow “”:

Me.RowTag(Me.ListCount - 1) = Accueilli_RS.Field("ID").StringValue

Then, the Window populating SQLite code in the COmboBox.Open Event is:

SQL_Cmd = "SELECT * FROM Accueillis WHERE ID='" + Me.RowTag(Me.ListIndex) + "';"