Howdy!
I've got a table with some contact information.
uid, emailaddy, username
The user name data is inconsistent... . some names are as Bill Jones, some are B.Jones and some are the email address as well.
I need to parse through the fields and where there is a space between the names, break them out into two separate fields.
I'm stumped!
Any direction would be greatly appreaciated!
Thanks!
6 4495 ADezii 8,834
Recognized Expert Expert @artemetis
Assuming your Table Name is tblNames, I know not very original, the following code will parse any Value in the userName Field that has a space in it, and Update two Fields named First and Last. But first: - If your Table Name is not tblNames, change it in the code.
- Add 2 Fields to your Table and name them First and Last. Should you name them differently, adjust the code accordingly.
- Download the Attachment to get a visual cue as to what is going on.
- Any questions concerning the code, feel free to ask.
- Dim MyDB As DAO.Database
-
Dim rstParseNames As DAO.Recordset
-
-
Set MyDB = CurrentDb
-
Set rstParseNames = MyDB.OpenRecordset("tblNames", dbOpenDynaset)
-
-
With rstParseNames
-
If Not .BOF And Not .EOF Then 'has at least 1 Record
-
Do While Not .EOF
-
If InStr(![UserName], " ") > 0 Then
-
.Edit
-
![First] = Left$(![UserName], InStr(![UserName], " ") - 1)
-
![Last] = Mid$(![UserName], InStr(![UserName], " ") + 1)
-
.Update
-
End If
-
.MoveNext
-
Loop
-
Else
-
'fall through
-
End If
-
End With
-
-
rstParseNames.Close
-
Set rstParseNames = Nothing
Thanks!
As it turns out, the table is slightly more complicated.
There is not only first and last name in there, but Middle initials, and some other crap, which at this point, i'm thinking is impossible to clean up.
We see questions like this, both here and elsewhere, over and over and over again! If the original data is as simple as FirstName LastName, or even FirstName MiddleInitial LastName, code can easily be written to handle the parsing. But it's usually not that simple when it comes to names!
It's usually things like FirstName LastName
FirstName MiddleInitial LastName
FirstName LastName Qualifier (Sr, Jr, III, etc)
Mr/Mrs FirstName LastName
Mr/Mrs FirstName MiddleInitial LastName
FirstName MiddleInitial LastName Title (M.D. Esq. CEO, etc) and so forth, including the two part LastNames, such as van Allen and that guy that Bush has been chasing for so long! And so, in the end, you usually end up having to visually inspecting all records and making adjustments accordingly.
If the majority of names are FirstName LastName, or FirstName MiddleInitial LastName, using code to start the parsing process and then inspecting the data and making corrections may be worth the trouble, especially if you're talking about a lot of records. It all depends.
BTW, the other similar PIA we see involves parsing addresses! Years ago I moonlighted, doing data entry for one of the largest banks in the world. They'd bought out another regional bank and were trying to convert/format the customer addresses to fall in line with their own system's formatting. After a team of 6 programmers spent 4 months trying to figure out how to do this "automatica lly" they finally bit the bullet and hired data input personnel to scan the data and make the corrections.
The bottom line is to remember the Cardinal Rule of Relational Databases: One Piece of Data/One Field!
Good Luck and Welcome to Bytes!
Linq ;0)>
Hahahahahahhaha !
Thanks guys for the replies........ .........
I love that Cardinal Rule, not so much a fan of cleaning up other people's crap!!!
Thanks again!!!
ADezii 8,834
Recognized Expert Expert @artemetis
I responded to a similar Thread not that long ago involving names which may/may not have Prefixes, Suffixes, First, Last, Titles, etc. As soon as I can retrieve it, I'll post the Link to it. It will definately point you in the right direction, but as Linq stated, there is no foolproof Method to accomplish this. Got it! http://bytes.com/topic/access/answer...unction-script NeoPa 32,579
Recognized Expert Moderator MVP @artemetis
ADezii's link will probably get you off to a good start.
As for handling 'other people's crap', we always hope they can pass us something clean and tidy, but don't rely too heavily on that. In the real world you're lucky if you get too much passed on that doesn't need a fair amount of 'cleaning out' ;D.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Peter A. Schott |
last post by:
I've got a file that seems to come across more like a dictionary from what I can
tell. Something like the following format:
###,1,val_1,2,val_2,3,val_3,5,val_5,10,val_10
###,1,val_1,2,val_2,3,val_3,5,val_5,11,val_11,25,val_25,967,val_967
In other words, different layouts (defined mostly by what is in val_1, val_2,
val_3).
The ,#, fields indicate what "field" from our mainframe the corresponding value
|
by: BStorm |
last post by:
I have a transaction log file where the DataSet table's Description column
is actually delimited into "subcolumns" based upon the transaction id. I
would like to parse these into separate fields for reporting purposes and am
wondering if anyone knows if this is easily accomplished using the .NET
version of Crystal Reports?
For example, the description column may be reporting on a dataentry error as
follows:
TXNCODE: 1010001
|
by: |
last post by:
Hi,
I need to read a big CSV file, where different fields should be converted to
different types,
such as int, double, datetime, SqlMoney, etc.
I have an array, which describes the fields and their types. I would like
to somehow store a reference to parsing operations in this array
(such as Int32.Parse, Double.Parse, SqlMoney.Parse, etc),
so I can invoke the appropriate one without writing a long switch.
|
by: Theresa Hancock via AccessMonster.com |
last post by:
I have an Excel table I need to import into Access. The name is entered into one field "Name". I'd like to have two fields in Access, FirstName and LastName. How do I do this.
--
Message posted via http://www.accessmonster.com
|
by: hoopsho |
last post by:
Hi Everyone,
I am trying to write a program that does a few things very fast
and with efficient use of memory...
a) I need to parse a space-delimited file that is really large,
upwards fo a million lines.
b) I need to store the contents into a unique hash.
c) I need to then sort the data on a specific field.
d) I need to pull out certain fields and report them to the user.
| |
by: Takeadoe |
last post by:
I've got a favor to ask -
Consider the following numeric field:
511
6805
3205
403
I need to make 2 new numeric fields from this variable, call it CS
|
by: RMC |
last post by:
Hello,
I'm looking for a way to parse/format a memo field within a report.
The Access 2000 database (application) has an equipment table that
holds a memo field. Within the report, the memo field is printed within
the detailed area. The problem is, the apllication is not setup
properly, thus the users are entering data within the memo field as:
location1 1/1/2005 1/1/2006
|
by: portCo |
last post by:
Hi there,
I am re-organizing the database. We used to have field 'names' in our
table for our first name and last name. However, I want to have those
names in different field.
FYI, I have two different tables in different databases. The A
database contains A table with 'names" field. The B database contains
B table with 'fname' and 'lname' I want to copy data A table to B
table.
|
by: jmDesktop |
last post by:
I have a food menu. Each area, like beverages, grill, etc. have items
under them, Coke, Tea, Coffee would be under beverages for example.
I want to add a new drink to beverages. In my database I have an
"area" like above, Bevs, Grill, Chicken... In my menu items I have an
ID from the area so,
table areas
id 1 areaname beverages
id 2 areaname grill
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |