473,396 Members | 2,002 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,396 software developers and data experts.

Parse first name space last name from email address containing first dot last name

MitchR
65 64KB
Howdy folks,
I am living the Access Dream as always but, I am in need of some helping hands here. I am looking to find a way to obtain First name space Last name from an email address of firstname.Lastname@Domain.com. My table Status_and_Updates has a column of Email_ADDR and I want to parse out the Firstname space lastname out of the email address. I can parse out the first name with a left function and I have tried and tried Right and Mid functions to parse out the lastname with no success I am affraid
Expand|Select|Wrap|Line Numbers
  1. Left([Status_and_Updates].[Email_ADDR],InStr([Status_and_Updates].[Email_ADDR],".")-1)+" "+Mid Function
I have come very close but I am not able to complete the function to parse just the last name from between the dot and the "@."
Aug 23 '18 #1
7 1975
NeoPa
32,556 Expert Mod 16PB
Hi Mitch.

You don't indicate whether this is in a query or in VBA. I'll start with a Public Function and you can say whether that works for you or whether the question needs to be amended :
Expand|Select|Wrap|Line Numbers
  1. Public Function GetNameFromSMTP(ByVal strSMTP As String) As String
  2.     strSMTP = Split(strSMTP, "@")(0)
  3.     GetNameFromSMTP = Split(strSMTP, ".")(0) & " " & Split(strSMTP, ".")(1)
  4. End Function
Aug 23 '18 #2
MitchR
65 64KB
Hi NeoPa,
Thank you so much in helping me with a solution. I am so sorry, I was just a little frustrated at the time I wrote my post. The answer to the question is that my formula is from a Query. I was looking for a way to parse the data from within the query itself.
Aug 23 '18 #3
NeoPa
32,556 Expert Mod 16PB
Well, as you'll probably have guessed, that's a lot more complicated - not to say awkward.
Expand|Select|Wrap|Line Numbers
  1. Left([Status_and_Updates].[Email_ADDR],InStr([Status_and_Updates].[Email_ADDR],'.')-1)+' '+Mid([Status_and_Updates].[Email_ADDR],InStr([Status_and_Updates].[Email_ADDR],'.')+1,InStr([Status_and_Updates].[Email_ADDR],'@')-InStr([Status_and_Updates].[Email_ADDR],'.')-1)
Or, made a little more readable in order to understand, we'll replace [Status_and_Updates].[Email_ADDR] with [X] :
Expand|Select|Wrap|Line Numbers
  1. Left([X],InStr([X],'.')-1)+' '+Mid([X],InStr([X],'.')+1,InStr([X],'@')-InStr([X],'.')-1)
PS. This means you can copy/paste the latter one then simply do a Find & Replace to turn it into what you need specifically.
Aug 24 '18 #4
Nauticalgent
100 64KB
Pardon me for jumping in here, but I thought this might be useful to others.

Why Team Access did not make the Split() Function available in the Query grid is beyond me, but thanks to Daniel Pineault, there is a pretty neat alternative:
<Link removed - feel free to search for it>
Aug 24 '18 #5
MitchR
65 64KB
Team,

Thank you so much for everyone helping me!

NeoPa, Your solution was absolutely on point. I cannot say thank you enough. As awkward as the query solution can be, it is absolute gold for my process on this app.

I really appreciate everyone's assistance and patience on this one.

Thank you again!

P.S. Indenting my code has been a tremendous help! Thank you!
Aug 24 '18 #6
NeoPa
32,556 Expert Mod 16PB
MitchR:
P.S. Indenting my code has been a tremendous help! Thank you!
Very pleased to hear it Mitch. It's a very important point.

Also pleased to hear that helped. As our NauticalGent has pointed out you can also call code in your project as long as it's declared as Public. That's why my first response could also have helped in this situation had you chosen to go that route.
Aug 24 '18 #7
NeoPa
32,556 Expert Mod 16PB
NauticalGent:
Pardon me for jumping in here, but I thought this might be useful to others.
No problem with that my friend.

Unfortunately, particularly as Daniel is a personal friend and fellow Access MVP, I was obliged to remove the link due to the site regulations on linking to other sites that are commercial and not sites provided by the provider of the software itself.

Nevertheless, the point is made. You can set up a wrapper function in your own project as long as it's defined as Public. BTW it's easier to use from a standard module but not absolutely necessary.

In this case though, unless you want a project that uses a variation of Split() from multiple different QueryDefs or other SQL, it makes better sense to provide a function to do the job itself. An example of that is in post #2.

NauticalGent:
Why Team Access did not make the Split() Function available in the Query grid is beyond me
QueryDefs, just like any part of access using SQL or expressions, is clearly not in the VBA environment. Jet/ACE SQL, which runs the SQL in an Access database, has access to The Expression Service (TES). TES has access to one/some of the most basic libraries that Access has, including your own project, but certainly not the VBA one. Split() is found as VBA.Strings.Split() - thus is unavailable to TES even though it's available to your projects VBA code. I hope that explains why MS never made Split() available to use in expressions - even though most of us would love to have it available ;-)
Aug 24 '18 #8

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

Similar topics

1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
3
by: Edmund Wong | last post by:
I have one client fiield that stores First and last name. I would like to separate the names into a lastname field and firstname field. Can anyone tell me how to do this? thanks
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
0
by: Peter | last post by:
Using CDO 1.21 how do I get First Name and Last Name from Global Address Book? I have the following code where I retrieve LastName and FirstName in one field, but how do I get LastName and...
0
by: preeti13 | last post by:
Hi friends i am here again with my probelm. i have one login page when first login on the page it is checking the active directory user exist or not if user exist then go the next page all i nee to...
1
by: hbkiwi | last post by:
Hi, Just playing with Access fairly new to it (like days old). Also it's my first post here so if I'm in the wrong place, sorry.. What I'm wanting to know is basically I have lets call it Table...
3
by: Mo Ewing | last post by:
I have a field in my database with people's names. Each field has only one first name but may have more than one last name. The first name is always the first word in the field. I would like to...
12
by: mcupito | last post by:
I have a text box where users will enter a first and last name, and then search by those parameters. I can find plenty of examples and have done search functions where first name and last name are...
6
MitchR
by: MitchR | last post by:
I need some help folks. I am trying to extract the first name space last name from an email address containing first name dot last name. I was able to complete a work around to extract first name....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...

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.