Results 1 to 13 of 13
  1. #1
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370

    Question Access storing email addresses

    Hello all,



    I'm having a little problem on how access is storing email addresses. Many emails are being stored as Myemailaddress@gmail.com#mailto:Myem...ss@gmai l.com#

    This is a problem because when I run a wordmerge, it pulls the email address and the "#mailto:#" part is included. I've done a manual scan to delete the #mailto:# part off the emails, but now several records have it again.

    The only solution I'm thinking of is having an update query run before the wordmerge starts to remove that part(#mailto:#). I'm just not sure what the syntax would be in SQL for the query.

    Any help would be great, thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Are you using the hyperlink data type (or format perhaps)? It stores that way. I would use the text data type.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Following expressions give the First and Last occurrence (position) of # within your field.
    FirstOccurrence : InStr(1,[EmailAddress],"#")
    LastOccurrence : InStrRev(EmailAddress],"#")
    You can then use the string functions Left/Mid/Right to get your desire output.

  4. #4
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Quote Originally Posted by pbaldy View Post
    Are you using the hyperlink data type (or format perhaps)? It stores that way. I would use the text data type.
    Yep, I am using the text data type field.

  5. #5
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Quote Originally Posted by amrut View Post
    Following expressions give the First and Last occurrence (position) of # within your field.
    FirstOccurrence : InStr(1,[EmailAddress],"#")
    LastOccurrence : InStrRev(EmailAddress],"#")
    You can then use the string functions Left/Mid/Right to get your desire output.
    Could you explain a little more what this does amrut? And would that be criteria of the query for the email field? I'm not sure what to do with the SQL you just gave me.

  6. #6
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    For ex. if the your email is like Myemailaddress@gmail.com#mailto:Myemss@gmai l.com#
    FirstOccurrence : InStr(1,[EmailAddress],"#") is 25
    LastOccurrence : InStrRev(EmailAddress],"#") = length of the email address field
    The required mail address is Mid([EmailAddress],1,[FirstOccurrence]-1)
    The LastOccurrence is not required if there you need the string before the first # tag only.
    The SQL looks like
    Code:
    SELECT tblCandidates.Candidate, InStr(1,[EmailAddress],"#") AS FirstOccurrence, InStrRev([EmailAddress],"#") AS LastOccurrence, Mid([EmailAddress],1,[FirstOccurrence]-1) AS ReqdMailAddress
    FROM tblCandidates;
    Hope this helps.
    Last edited by amrut; 01-05-2015 at 10:03 AM. Reason: Added SQL

  7. #7
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Ok, I'll tinker with this for a bit, thanks amrut and pbaldy.

    And yeah I don't have to worry about any text after the first "#"

    I won't mark as solved until I've figured it out! I may need more help

  8. #8
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Ok so I got that query working, Now how would I make the [ReqdMailAddress] replace the existing one?

    and also, for all emails that didn't have the "#mailto:#" the query returned them as #Func!, I'm guessing thats how its supposed to be.

  9. #9
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Now how would I make the [ReqdMailAddress] replace the existing one?
    Use the expression in an UPDATE query to replace the existing records
    for all emails that didn't have the "#mailto:#" the query returned them as #Func!
    In this case the FirstOccurence must be 0, use <>0 in the criteria to exclude those records.

  10. #10
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Hmm, when I change and run it as an update query it just returns the one column "Email" and doesn't make the change. In the query builder i had "Email" updating to "ReqdMailAddress" is that correct?

  11. #11
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Example SQL for update query
    Code:
    UPDATE tblCandidates SET tblCandidates.EmailAddress = Mid([EmailAddress],1,InStr(1,[EmailAddress],"#")-1);

  12. #12
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    I'm very slow at this... Ok so that SQL just returns the emails without any change, the other SQL you gave me actually shows the change but it doesn't apply the update.

    Am I supposed to join the two SQL statements together?

    Why am I so lost at this right now? lol, I feel like its really simple. I just want to get rid of the # and anything that follows and update that as the new record.

    EDIT: So I ran the update SQL you provided and it deleted all the Emails that didn't have "#mailto:# however, the ones that had #mailto# are now correct! How would I set the criteria in the more recent SQL you gave me to only apply it to Emails that contain "#" or "#mailto:"

    EDIT 2: What am I doing wrong?
    Code:
    UPDATE [Contact Table] SET [Contact Table].[Email - Primary] = Mid([Email - Primary],1,InStr(1,[Email - Primary],"#")-1)
    WHERE ((([Contact Table].[Email - Primary]) LIKE '%#mailto%'));
    EDIT 3: Got it! Thanks for helping amrut
    Last edited by cbende2; 01-05-2015 at 01:28 PM. Reason: Got it!

  13. #13
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Add a column to query having expression InStr(1,[EmailAddress],"#") and put >0 in criteria row. Leave the "Update to" blank for this column.

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

Similar Threads

  1. Send email using CDO, get email addresses from table
    By marvinac1 in forum Programming
    Replies: 3
    Last Post: 12-22-2014, 12:54 PM
  2. Replies: 3
    Last Post: 08-16-2013, 04:15 PM
  3. Replies: 11
    Last Post: 05-20-2011, 01:56 PM
  4. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM
  5. Combining two Email Addresses
    By Frodo in forum Access
    Replies: 0
    Last Post: 09-16-2007, 07:07 AM

Tags for this Thread

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