473,698 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query for getting domain suffix from E-mail address field?

Jan
I'd like a maketable query listing ClientID, and E-mail from another
table. This is simple, BUT I'd only like to get only the part after @
in the E-mail.

How would this work in MS Access 2003?

Oct 21 '06 #1
11 5837

Jan wrote:
I'd like a maketable query listing ClientID, and E-mail from another
table. This is simple, BUT I'd only like to get only the part after @
in the E-mail.

How would this work in MS Access 2003?
Something like...
Right$([email],len$([email])-InStr(1,[email],"@"))

Oct 22 '06 #2
Jan
Looks good, but for some strange reason Access says LEN is an undefined
function, I've pasted the sentence into the "field" field in the query.
LEN is a function when I check in Help...

pi********@hotm ail.com wrote:
Jan wrote:
I'd like a maketable query listing ClientID, and E-mail from another
table. This is simple, BUT I'd only like to get only the part after @
in the E-mail.

How would this work in MS Access 2003?

Something like...
Right$([email],len$([email])-InStr(1,[email],"@"))
Oct 22 '06 #3
Hi,
>Right$([email],len$([email])-InStr(1,[email],"@"))
Looks good, but for some strange reason Access says LEN is an
undefined function, I've pasted the sentence into the "field" field
in the query. LEN is a function when I check in Help...
You could try

Mid(Email,instr (Email,"@"))

But I think it's better to check your references :

http://support.microso ft.com/kb/825796/en-us

Regards
Jens
Oct 22 '06 #4
Hi,
Mid(Email,instr (Email,"@"))
Sorry, so it's wrong, try :

Mid(Email,instr (Email,"@") +1 )

Regards
Jens

Oct 22 '06 #5
Jan
Thanks, MID works great :-)

My next challange is for domains to extract only the the last 2 levels,
like yahoo.com instead of server1.server. usa.yahoo.com

Jens Schilling wrote:
Hi,
Right$([email],len$([email])-InStr(1,[email],"@"))
Looks good, but for some strange reason Access says LEN is an
undefined function, I've pasted the sentence into the "field" field
in the query. LEN is a function when I check in Help...

You could try

Mid(Email,instr (Email,"@"))

But I think it's better to check your references :

http://support.microso ft.com/kb/825796/en-us

Regards
Jens
Oct 22 '06 #6
Hi,
My next challange is for domains to extract only the the last 2
levels, like yahoo.com instead of server1.server. usa.yahoo.com
That's all after the last but one dot, so try :

Function Get2Level(strDo main As String)
Dim i As Long, j As Long

i = InStr(1, StrReverse(strD omain), ".")
j = InStr(i + 1, StrReverse(strD omain), ".")

Get2Level = right(strDomain , j - 1)

End Function

Test in direct window :

?Get2Level("ser ver1.server.usa .yahoo.com")
yahoo.com

Regards
Jens
Oct 22 '06 #7
Jan
How do I insert the function? I'm not used to programming in queries.
Trying to paste the code into the query only produces syntax error.

Where do I paste it?

Jens Schilling wrote:
Hi,
My next challange is for domains to extract only the the last 2
levels, like yahoo.com instead of server1.server. usa.yahoo.com

That's all after the last but one dot, so try :

Function Get2Level(strDo main As String)
Dim i As Long, j As Long

i = InStr(1, StrReverse(strD omain), ".")
j = InStr(i + 1, StrReverse(strD omain), ".")

Get2Level = right(strDomain , j - 1)

End Function

Test in direct window :

?Get2Level("ser ver1.server.usa .yahoo.com")
yahoo.com

Regards
Jens
Oct 22 '06 #8
Hi,
How do I insert the function? I'm not used to programming in queries.
Trying to paste the code into the query only produces syntax error.
First you have to save the function in a (standard) modul.
Where do I paste it?
In your query you have to add a new column and insert something like this:

My2Level: Get2level([YourFieldName])

Where you have to replace < YourFieldName with the name of the field
containing the domain name.

But be aware - using such a function in a query won't be very fast.....

Regards
Jens


Oct 22 '06 #9
Jan
Getting run-time error 5, invalid procedure call or argument.

Seems like j=0 in the last line, i.e. j-1= -1 which might be why error
occurs. If doing i-1 instead i+1, it works - but then I only get the
last part of the domain instead of including the part before.

Jens Schilling wrote:
Hi,
How do I insert the function? I'm not used to programming in queries.
Trying to paste the code into the query only produces syntax error.

First you have to save the function in a (standard) modul.
Where do I paste it?

In your query you have to add a new column and insert something like this:

My2Level: Get2level([YourFieldName])

Where you have to replace < YourFieldName with the name of the field
containing the domain name.

But be aware - using such a function in a query won't be very fast.....

Regards
Jens
Oct 22 '06 #10

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

Similar topics

8
2459
by: manish | last post by:
I have created a function, it gives more readability compared to the print_r function. As of print_r, it works both for array or single variable. I just want to add in it, the opton to view the variable name for the case of non array variables. Also I want to show the array name. Is there any way that the variable name that is passed to the function can be displayed. function formattedoutput($object) {
1
4102
by: writeson | last post by:
Hi all, I'm working on a project at the office that pulls together a bunch of our websites into a portal thing and adds a better search engine. We're also trying to accomadate newer browsers (Netscape 7.2, Firefox, Safari) and are having some problems. The websites run on different servers, all of which we control, so we are setting the document.domain = "ourdomain.com"; in some javascript on ever page. However, we're having problems....
13
5174
by: gsecrets | last post by:
Hi friends.. I have a table with the following ..... fields URL Domain The domain name has the following suffix ..edu, .com, .org, .ca.org etc;
1
1352
by: owenmj | last post by:
I have a written a web service which takes some user input and then looks up the relevant details on a SQL server. All works fine until I embed it in the Research pane - at which point I receive no query text when I invoke the service I'm deploying the service on my local machine so is there an IIS setting that I have not set that stops the data being received? ..or is the code wrong?
7
16524
by: kooch54 | last post by:
I am trying to write a script to simply query the group members in an active directory group. I need to use LDAP to make sure I capture any global global group nestings that may occur. I already have a function that uses WinNT provider to capture this info from NT4 or AD domains and it works beautifully. It just doesn't capture global > global nestings. I am having great difficulties in getting this to work on AD though with ldap. I...
3
2558
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks like the following: <a href="?searchtype=2">Community</a>
2
2849
by: kelly.pearson | last post by:
Is this a bug? I am trying to write a cookie that can be accessed by various .Net applications on our domain. However, whenever I add the domain property to the cookie, no errors get thrown but the cookie doesn't get written. I am trying this from my localhost using vs2003, .net framework 1.1, windows xp prof. Sample code I am testing with is below. Public Class WebForm1 Inherits System.Web.UI.Page
1
992
by: suganya | last post by:
I have the 2 sql tables DoctorMaster DRID nvarchar(50) FirstName nvarchar(100) LastName nvarchar(100) Gender bit Address1 nvarchar(255) Address2 nvarchar(255)
4
1226
by: suganya | last post by:
DoctorMaster DRID nvarchar(50) FirstName nvarchar(100) LastName nvarchar(100) Gender bit Address1 nvarchar(255) Address2 nvarchar(255) City nvarchar(100) Pincode numeric(6,0)
0
1356
by: Aguyngueran | last post by:
Hello there, How to remove domain name suffix US.ORACLE.COM for GLOBAL_DB_NAME in default templates, e.g. General Purpose, or another way to ask: where this information is stored ? Best regards Grzybowski Rafal
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
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
9031
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
8901
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,...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4371
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
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.