Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Valdiate Email Entry? 1

Status
Not open for further replies.

Bronte1226

Technical User
Oct 18, 2002
123
0
0
US
How do you create a validation check on a field entry after it is entered? I need to force the user to input a correct email address (making sure there is a "@" in the address as well as a "." if possible.
 
Bronte1226,

Something like this may work for you...

Code:
Function IsValidEmailAddress(Candidate As String) As Boolean

    If Trim(Candidate) Like "?*@[!.]*.[!.]*" Then
       If Not Candidate Like "*@*@*" Then
           IsValidEmailAddress = True
       End If
   End If

End Function

I hope this helps... [thumbsup2]


 
In the BeforeUpdate event procedure of the textbox:
If Not Me![textbox name] Like "*@*.*" Then
MsgBox "Please enter a valid email address"
Cancel = True
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
If you are doing the entry from a form, you could try writing a bit of VB to do a pattern match.

ie.

function emvalid(inEmailAddress as string) as boolean
const pattern = "*@*.*"
emvalid = false
if inEmailAddress like pattern then emvalid = true
end function

Then, after the user has entered the data, using the [After Update] event, you could call then and send a message to the user.

p.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top