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? 11 5772
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],"@"))
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********@hotmail.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],"@"))
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.microsoft.com/kb/825796/en-us
Regards
Jens
Hi,
Mid(Email,instr(Email,"@"))
Sorry, so it's wrong, try :
Mid(Email,instr(Email,"@") +1 )
Regards
Jens
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.microsoft.com/kb/825796/en-us
Regards
Jens
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(strDomain As String)
Dim i As Long, j As Long
i = InStr(1, StrReverse(strDomain), ".")
j = InStr(i + 1, StrReverse(strDomain), ".")
Get2Level = right(strDomain, j - 1)
End Function
Test in direct window :
?Get2Level("server1.server.usa.yahoo.com")
yahoo.com
Regards
Jens
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(strDomain As String)
Dim i As Long, j As Long
i = InStr(1, StrReverse(strDomain), ".")
j = InStr(i + 1, StrReverse(strDomain), ".")
Get2Level = right(strDomain, j - 1)
End Function
Test in direct window :
?Get2Level("server1.server.usa.yahoo.com")
yahoo.com
Regards
Jens
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
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
Hi,
Getting run-time error 5, invalid procedure call or argument.
Guess you have some records not matching your example (e.g. "yahoo.com") -
so there's no second dot in the string.
You can check the value of <j...
Function Get2Level(strDomain As String)
Dim i As Long, j As Long
i = InStr(1, StrReverse(strDomain), ".")
j = InStr(i + 1, StrReverse(strDomain), ".")
If j 0 Then
Get2Level = right(strDomain, j - 1)
Else
Get2Level = strDomain
End If
End Function
Regards
Jens
Thanks - yes, you're right I have some yahoo.com and some usa.yahoo.com
domains in the table. It works with the latest code.
Jens Schilling wrote:
Hi,
Getting run-time error 5, invalid procedure call or argument.
Guess you have some records not matching your example (e.g. "yahoo.com") -
so there's no second dot in the string.
You can check the value of <j...
Function Get2Level(strDomain As String)
Dim i As Long, j As Long
i = InStr(1, StrReverse(strDomain), ".")
j = InStr(i + 1, StrReverse(strDomain), ".")
If j 0 Then
Get2Level = right(strDomain, j - 1)
Else
Get2Level = strDomain
End If
End Function
Regards
Jens
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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;
|
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...
|
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...
|
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...
|
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...
|
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)
|
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)
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
| |