Results 1 to 5 of 5
  1. #1
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17

    Parsing e-mail addresses

    I need to parse (separate out) the parts the field containing e-mail address for display in a select query..



    In the results I need to take a field 'emailaddress@hotmail.com' and display it a calculated expression as 'emailaddress' in one field and as "hotmail.com" in another field... so I can filter on the email provider...essentially removing everything to the right or left of the ampersand.. including the ampersand.

    My returned data should look like this..
    Field1 Field2 Field2
    emailaddress@hotmail.com emailaddress hotmail.com

    I don't want to change the source data.. just parse for viewing / filtering purposes. I tried the code...

    StaffStu: Right(Trim([EmailAddress]),Len(Trim([EmailAddress]))@InStr(1,[Emailaddress],""))

    But it errors on the Ampersand.

    Any help would be appreciated!

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try this:

    URL_Front: Left([Emailaddress],InStr([emailaddress],"@")-1)
    URL_Back: Right([emailaddress],InStr([emailaddress],"@")-2)

    This is the query SQL:
    Code:
    SELECT Table1.emailaddress, Left([Emailaddress],InStr([emailaddress],"@")-1) AS URL_Front, Right([emailaddress],InStr([emailaddress],"@")-2) AS URL_Back
    FROM Table1;



    BTW,
    This is the "at" sign-> @
    This is the Ampersand -> &

  3. #3
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17
    The first line you suggested (URL_Front: Left([Emailaddress],InStr([emailaddress],"@")-1)) works fine. The second line which should return everything after the @ sign returns varying numbers of the characters to the right... not consistent from record to record.

    Quote Originally Posted by ssanfu View Post
    Try this:

    URL_Front: Left([Emailaddress],InStr([emailaddress],"@")-1)
    URL_Back: Right([emailaddress],InStr([emailaddress],"@")-2)

    This is the query SQL:
    Code:
    SELECT Table1.emailaddress, Left([Emailaddress],InStr([emailaddress],"@")-1) AS URL_Front, Right([emailaddress],InStr([emailaddress],"@")-2) AS URL_Back
    FROM Table1;



    BTW,
    This is the "at" sign-> @
    This is the Ampersand -> &

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Sorry... had my Doh!! hat on


    OK, I tested with 3 addresses.....

    URL_Front: Left([Emailaddress],InStr([emailaddress],"@")-1)
    URL_Back: Right([emailaddress],Len([emailaddress])-InStr([emailaddress],"@"))

    Code:
    SELECT Table1.emailaddress, Left([Emailaddress],InStr([emailaddress],"@")-1) AS URL_Front, Right([emailaddress],Len([emailaddress])-InStr([emailaddress],"@")) AS URL_Back
    FROM Table1;

  5. #5
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17
    Thanks... I also discovered the "MID" command works too.

    Again.. thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 12-13-2013, 03:13 PM
  2. Replies: 1
    Last Post: 09-14-2012, 10:27 AM
  3. VBA to Send E-mail to Addresses from Query
    By alpinegroove in forum Programming
    Replies: 4
    Last Post: 12-23-2011, 09:45 AM
  4. parsing for addition
    By imintrouble in forum Reports
    Replies: 6
    Last Post: 10-27-2011, 03:00 PM
  5. Replies: 11
    Last Post: 09-12-2011, 11:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums