Results 1 to 5 of 5
  1. #1
    Phil1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    14

    Validating Email Address in VBA

    I'm trying to validate an entered email address in a text Box.

    The VBA code i'm using is:

    If (Not IsNull(EdEmail.Value)) And ((Not EdEmail.Value Like "?*@?*.*?") Or (Not EdEmail.Value Like "*?.?*@?*.*?") Or (EdEmail.Value Like "*[!0-9a-z@._+-;, ]*")) Then
    msgbox "Invalid email"
    end If


    .....


    No matter what I enter it gives the error.

    Can anyone help?

    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Google: Access VBA valid email address

    Does this help http://www.geeksengine.com/article/v...email-vba.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Phil1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    14
    Hi June7.

    Thanks for your reply.

    If I followed this tutorial and gave the database to someone else, would they also need to do the same thing in the menu?

    I'd prefer it if gave it to someone, all they'd need to do is open it and away they go.

    Thanks.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Sorry, I did not thoroughly read that link, only saw that pattern matching and that looked applicable. I have never used the Regular Expression functionality, wasn't even aware of it.

    Yes, with that code the user would have to set library reference. There may be other ways to write code so library reference not needed. Review: http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    Otherwise, Google for other ideas: Access VBA validate email address

    Maybe this one http://www.vbaexpress.com/kb/getarticle.php?kb_id=281
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Phil1 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    14
    Thanks June7, I appreciate your thoughts on this.

    I've tried googling and returned varied results, even found the reference you suggested first. I like to keep things simple myself, and to me a simple LIKE query seems like it should do the trick but for some reason my code above thinks anything is wrong.
    So long as I have it correct, that '*' means 'any string - any length' then I can't see why its going wrong.

    I'll be looking at it again tonight.

    Thanks again,

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

Similar Threads

  1. Adding a email address on form
    By akhlaq768 in forum Forms
    Replies: 3
    Last Post: 02-07-2012, 09:11 AM
  2. SendObject and No Email Address
    By Tomfernandez1 in forum Forms
    Replies: 6
    Last Post: 10-06-2011, 05:15 PM
  3. Multiple Email Address
    By Tomfernandez1 in forum Forms
    Replies: 15
    Last Post: 09-15-2011, 01:52 PM
  4. Generating emails with email-address in body
    By techexpressinc in forum Programming
    Replies: 1
    Last Post: 08-17-2011, 01:48 PM
  5. Passing Email Address Into Outlook
    By cg1465 in forum Access
    Replies: 1
    Last Post: 10-01-2010, 07:59 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