A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Email Validation



 
 
Thread Tools Display Modes
  #1  
Old January 27th, 2010, 05:51 PM posted to microsoft.public.access.tablesdbdesign
Steve Stad
external usenet poster
 
Posts: 89
Default Email Validation

I was testing this email validation rule.
Is Null Or ((Like ") Or (Like ") Or (Like ")
Or (Like ") Or (Like ") And (Not Like "*[ ,;]*" And Not
Like "*.@*"))

...but noticed I was able to input
... e.g., I was trying to prevent user typing a .@ [that is a dot@] using
the ... And Not Like "*.@*")) .. but it must be getting cancelled out by
something previous in the validation string. Any suggestions?

  #2  
Old January 28th, 2010, 01:30 AM posted to microsoft.public.access.tablesdbdesign
Daniel Pineault
external usenet poster
 
Posts: 658
Default Email Validation

You could use a routine such as:

Public Function isValidEmail(inEmailAddress As String) As Boolean
On Error GoTo Error_Handler
' Author: Unknown

If (Len(inEmailAddress) = 0) Then
MsgBox "Please enter your email address."
isValidEmail = False
Exit Function
End If
If (InStr(1, inEmailAddress, "@") = 0) Then
MsgBox "The '@' is missing from your e-mail address."
isValidEmail = False
Exit Function
End If
If (InStr(1, inEmailAddress, ".") = 0) Then
MsgBox "The '.' is missing from your e-mail address."
isValidEmail = False
Exit Function
End If

If (InStr(inEmailAddress, "@.") 0) Then
MsgBox "There is nothing between '@' and '.'"
isValidEmail = False
Exit Function
End If
If (InStr(inEmailAddress, ".@") = 1) Then
MsgBox "Your e-mail cannot start by '.@'"
isValidEmail = False
Exit Function
End If
If ((InStr(inEmailAddress, ".")) = ((Len(inEmailAddress)))) Then
MsgBox "There has to be something after the '.'"
isValidEmail = False
Exit Function
End If

If ((Len(inEmailAddress)) (InStr(inEmailAddress, ".") + 2)) Then
MsgBox "There should be two letters after the '.'"
isValidEmail = False
Exit Function
End If

If (InStr(1, inEmailAddress, "@") = 1) Then
MsgBox "You have to have something before the '@'"
isValidEmail = False
Exit Function
End If

isValidEmail = True

Error_Handler_Exit:
On Error Resume Next
Exit Function

Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: isValidEmail" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Steve Stad" wrote:

I was testing this email validation rule.
Is Null Or ((Like ") Or (Like ") Or (Like ")
Or (Like ") Or (Like ") And (Not Like "*[ ,;]*" And Not
Like "*.@*"))

..but noticed I was able to input
.. e.g., I was trying to prevent user typing a .@ [that is a dot@] using
the ... And Not Like "*.@*")) .. but it must be getting cancelled out by
something previous in the validation string. Any suggestions?

  #3  
Old January 28th, 2010, 05:50 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Email Validation

There are way too many valid variations for a validation rule like that,
e.g. .COM, .INFO, .NET, .ORG, .ME, .MOBI, .BIZ, .MX, .WS, .NAME,
..BZ, .COM.BZ, .NET.BZ, .CC, .ES, .COM.ES, .NOM.ES, .ORG.ES, .COM.MX,
..NL, .TV, as well as lots of other country codes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Steve Stad" wrote in message
...
I was testing this email validation rule.
Is Null Or ((Like ") Or (Like ") Or (Like ")
Or (Like ") Or (Like ") And (Not Like "*[ ,;]*" And Not
Like "*.@*"))

..but noticed I was able to input
.. e.g., I was trying to prevent user typing a .@ [that is a dot@] using
the ... And Not Like "*.@*")) .. but it must be getting cancelled out by
something previous in the validation string. Any suggestions?

  #4  
Old January 28th, 2010, 05:05 PM posted to microsoft.public.access.tablesdbdesign
Steve Stad
external usenet poster
 
Posts: 89
Default Email Validation

Daniel,

Thank you for the code sample. Just wondering where (what event) to place
the code. I would assume the AfterUpdate() event but since I am not a
programmer I need to ask. Also, I assume I need to change 'inEmailAddress'
in the code to my field name 'EMP_EMAIL_ADDRESS'.

"Daniel Pineault" wrote:

You could use a routine such as:

Public Function isValidEmail(inEmailAddress As String) As Boolean
On Error GoTo Error_Handler
' Author: Unknown

If (Len(inEmailAddress) = 0) Then
MsgBox "Please enter your email address."
isValidEmail = False
Exit Function
End If
If (InStr(1, inEmailAddress, "@") = 0) Then
MsgBox "The '@' is missing from your e-mail address."
isValidEmail = False
Exit Function
End If
If (InStr(1, inEmailAddress, ".") = 0) Then
MsgBox "The '.' is missing from your e-mail address."
isValidEmail = False
Exit Function
End If

If (InStr(inEmailAddress, "@.") 0) Then
MsgBox "There is nothing between '@' and '.'"
isValidEmail = False
Exit Function
End If
If (InStr(inEmailAddress, ".@") = 1) Then
MsgBox "Your e-mail cannot start by '.@'"
isValidEmail = False
Exit Function
End If
If ((InStr(inEmailAddress, ".")) = ((Len(inEmailAddress)))) Then
MsgBox "There has to be something after the '.'"
isValidEmail = False
Exit Function
End If

If ((Len(inEmailAddress)) (InStr(inEmailAddress, ".") + 2)) Then
MsgBox "There should be two letters after the '.'"
isValidEmail = False
Exit Function
End If

If (InStr(1, inEmailAddress, "@") = 1) Then
MsgBox "You have to have something before the '@'"
isValidEmail = False
Exit Function
End If

isValidEmail = True

Error_Handler_Exit:
On Error Resume Next
Exit Function

Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: isValidEmail" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Steve Stad" wrote:

I was testing this email validation rule.
Is Null Or ((Like ") Or (Like ") Or (Like ")
Or (Like ") Or (Like ") And (Not Like "*[ ,;]*" And Not
Like "*.@*"))

..but noticed I was able to input
.. e.g., I was trying to prevent user typing a .@ [that is a dot@] using
the ... And Not Like "*.@*")) .. but it must be getting cancelled out by
something previous in the validation string. Any suggestions?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:31 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.