Results 1 to 5 of 5
  1. #1
    something is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    13

    Validation rule for email

    Hiya,



    I having trouble to write a validation rule so that it check at the end of the email address it has .com or .co.uk or .org.

    I tried this [CODE]Like “[A-Z]* @[A-Z].com” OR “[A-Z]* @[A-Z].co.uk” OR “[A-Z]* @[A-Z].net” OR “[A-Z]* @[A-Z].org”[/CODE]

    And this
    Code:
    ((Like "*?.com?*") Or ((Like "*?co.uk?*") Or ((Like "*?.org?*"))))
    And error message appeared

    I have no idea what to do

    Thanks

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You can't use Like in VBA, only in queries.

    If Right(fieldname,4)=".com" OR Right(fieldname,6)=".co.uk" OR ........

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You can't use Like in VBA, only in queries.
    Do you have a reference for this??

    I use it in vba quite often.

    Code:
    If Left(Me.txtSearchValue, 1) Like "[0-9]" Then
           'searching for number
    Code:
    Do Until .EOF
    70       .FindFirst "Log like '*Nix *'"
    Code:
    60     If qdf.SQL Like "*Conca*" Then
    70     Debug.Print i & " ***" & qdf.name & "***" & vbCrLf & qdf.SQL

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    OK, I must be mistaken! Not sure why it has never worked for me. Nice to know.

  5. #5
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    First, when you declare an error message occurred, provide the error number and most, if not all, of the error message.
    Using two wildcard characters with Like just looks wrong - Like "*?.com?*" - Moreso LIKE "*.com" or LIKE "*.com*"

    If you're writing code, you could also use multiple instances of the InStr function. Assuming you are checking against a form field on the active form:

    If Instr([Me].[txtEmail],".com") Then

    Instr function details here
    https://www.techonthenet.com/access/...ring/instr.php
    Last edited by Micron; 10-29-2016 at 10:53 PM. Reason: square brackets might be necessary
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Email Validation Rule
    By something in forum Access
    Replies: 3
    Last Post: 10-29-2016, 09:44 AM
  2. Replies: 2
    Last Post: 06-16-2015, 03:52 AM
  3. Validation Rule
    By rbiggs in forum Forms
    Replies: 4
    Last Post: 08-23-2011, 05:24 PM
  4. Help with validation rule
    By Desstro in forum Programming
    Replies: 5
    Last Post: 02-27-2011, 08:05 PM
  5. Validation Rule
    By Christopher in forum Forms
    Replies: 15
    Last Post: 04-20-2010, 06:05 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