473,804 Members | 3,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse fields in table

76 New Member
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!
Jan 5 '09 #1
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:
  1. If your Table Name is not tblNames, change it in the code.
  2. Add 2 Fields to your Table and name them First and Last. Should you name them differently, adjust the code accordingly.
  3. Download the Attachment to get a visual cue as to what is going on.
  4. Any questions concerning the code, feel free to ask.
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database
  2. Dim rstParseNames As DAO.Recordset
  3.  
  4. Set MyDB = CurrentDb
  5. Set rstParseNames = MyDB.OpenRecordset("tblNames", dbOpenDynaset)
  6.  
  7. With rstParseNames
  8.   If Not .BOF And Not .EOF Then     'has at least 1 Record
  9.     Do While Not .EOF
  10.       If InStr(![UserName], " ") > 0 Then
  11.         .Edit
  12.           ![First] = Left$(![UserName], InStr(![UserName], " ") - 1)
  13.           ![Last] = Mid$(![UserName], InStr(![UserName], " ") + 1)
  14.         .Update
  15.       End If
  16.       .MoveNext
  17.     Loop
  18.   Else
  19.     'fall through
  20.   End If
  21. End With
  22.  
  23. rstParseNames.Close
  24. Set rstParseNames = Nothing
Jan 6 '09 #2
artemetis
76 New Member
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.
Jan 6 '09 #3
missinglinq
3,532 Recognized Expert Specialist
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)>
Jan 6 '09 #4
artemetis
76 New Member
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!!!
Jan 6 '09 #5
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
Jan 6 '09 #6
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.
Jan 6 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

19
2480
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
5
3028
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
24
3178
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.
5
16604
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
11
3627
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.
5
1962
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
9
5741
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
5
4355
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.
14
1807
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
0
10580
Oralloy
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...
0
10335
jinu1996
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...
1
10323
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,...
0
9157
agi2029
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...
0
6854
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();...
0
5525
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...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.