473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Parsing out Firstname from Given Names

I am using an update query to parse out the Firstname of a person from a
field (GivenNames) in a list of names. The criteria I am using is

Left([GivenNames],InStr(1,[GivenNames]," ")-1)

This works fine if the person actually has more than one name, but gives me
errors if the person only has one name in the first place and puts a null
into the Firstname field in that instance. How can I get it to just copy
the single name into the Firstname field for cases where the person only has
one first name?

dixie
Nov 12 '05 #1
3 1089
Dixie,

For cases where the person only has one first name, there will be no space.
InStr(1,[GivenNames]," ") returns 0 when there is no space. Maybe you can work
that into what you are doing.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"dixie" <di****@dogmail.com> wrote in message
news:Lb****************@nnrp1.ozemail.com.au...
I am using an update query to parse out the Firstname of a person from a
field (GivenNames) in a list of names. The criteria I am using is

Left([GivenNames],InStr(1,[GivenNames]," ")-1)

This works fine if the person actually has more than one name, but gives me
errors if the person only has one name in the first place and puts a null
into the Firstname field in that instance. How can I get it to just copy
the single name into the Firstname field for cases where the person only has
one first name?

dixie

Nov 12 '05 #2

"dixie" <di****@dogmail.com> wrote in message
news:Lb****************@nnrp1.ozemail.com.au...
I am using an update query to parse out the Firstname of a person from a
field (GivenNames) in a list of names. The criteria I am using is

Left([GivenNames],InStr(1,[GivenNames]," ")-1)

This works fine if the person actually has more than one name, but gives me errors if the person only has one name in the first place and puts a null
into the Firstname field in that instance. How can I get it to just copy
the single name into the Firstname field for cases where the person only has one first name?

dixie


I think this will do what you describe:

Iif(InStr([GivenNames], " ") > 0, Left([GivenNames],InStr(1,[GivenNames],"
")-1), [GivenNames])

HTH,
Randy
Nov 12 '05 #3
Sure does, thanks Randy.
I have also learned that I can use an IIf statement in a query which I would
not have suspected previously.

dixie

"Randy Harris" <ra***@SpamFree.com> wrote in message
news:My*******************@newssvr15.news.prodigy. com...

"dixie" <di****@dogmail.com> wrote in message
news:Lb****************@nnrp1.ozemail.com.au...
I am using an update query to parse out the Firstname of a person from a
field (GivenNames) in a list of names. The criteria I am using is

Left([GivenNames],InStr(1,[GivenNames]," ")-1)

This works fine if the person actually has more than one name, but gives me
errors if the person only has one name in the first place and puts a null into the Firstname field in that instance. How can I get it to just copy the single name into the Firstname field for cases where the person only

has
one first name?

dixie


I think this will do what you describe:

Iif(InStr([GivenNames], " ") > 0,

Left([GivenNames],InStr(1,[GivenNames]," ")-1), [GivenNames])

HTH,
Randy

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: george young | last post by:
For each run of my app, I have a known set of (<100) wafer names. Names are sometimes simply integers, sometimes a short string, and sometimes a short string followed by an integer, e.g.: 5, 6,...
5
by: Chris Vendel | last post by:
I'm in doubt as to how best to handle the following 'challenge'... I want to render an XML file from two XML sources. One is a template and the other (if available) contains data I wish to add....
3
by: dixie | last post by:
I am using an update query to parse out the Firstname of a person from a field (GivenNames) in a list of names. The criteria I am using is Left(,InStr(1,," ")-1) This works fine if the person...
2
by: Ben Fidge | last post by:
Hi I'm trying (and failing) to create and regular expression for parsing peoples names. I simply want to make sure that a firstname and surname, at least, can be extracted. For example, "Ben...
6
by: Netmonster | last post by:
Hello all, I am creating a string based on data returned from an oracle db into a hashtable. string tmpFirstName = tmphashtable.ToString(); The Database has a column called FIRST_NAME but...
7
by: hal | last post by:
Hello, I'm a beginner to C# programming and working on some exercises. I have form where a user enters their name and when they click on a button it parses their name and puts it on 3 seperate...
7
by: sbowman | last post by:
I have a completely lame string parsing question, but I need an answer fast and I know this is where to get it...I'm not completely familiar with the Len, Right, Left, and mid functions and I have...
4
by: william | last post by:
Hello, I've imported an excel spreadsheet with a Name column which is formatted as Last, First, MI. Some examples I have in the Name column: Smith, Ellen P. Jones, Mary Jane...
1
by: danep | last post by:
Hi, I'm fairly new to AJAX, but I've been able to retrieve HTML and plain-text documents without any trouble. However, I haven't figured out how to retrieve it in XML format. Basically, here's...
5
by: moddster | last post by:
Hi Guys. I am a newbie to perl and need some help with a problem. PROBLEM: I have to parse an HTML file and get rid of all the HTML tags and count the number of sumbissions a person has through...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.