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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation rule for E-mail field

Status
Not open for further replies.

LeiDBug007

Technical User
Oct 15, 2003
33
US
Greetings,

We're trying to set-up a validation rule for an E-mail field where the user cannot leave the field unless they place the "@" symbol. Just trying to avoid as much room for error as possible.

What would be the validation rule so that once they input the e-mail address, if they don't place the "@" symbol they will get our validation text/error message?

Thanx!
 
write a small function that fire on the before update event or the onLostFocus event that checks for the proper format for an email

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
If Not Me![Text0] Like "*@*" Or Not Me![Text0] Like "*.*" Then
MsgBox ("Invalid e-mail address")
End If

will check to make sure there is a "@" and at least one "." in the address....which should be correct in most cases.

****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Greetings mstrmage1768 ,

Thanx for the coding, it works and I get my error message when the user doesn't include the "@" symbol.

However, it still allows the user to leave the field without correcting the e-mail address entry, by adding the "@" symbol?

I need an additional string to lock them to the field until they correct the e-mail address.

Your expertise is much needed... thanx again!
 
Try adding a "me.text0.setfocus" before the "End If"...but it should work without that if the code is in the "Before Update" of the text box.

 
Try chaning the code to this if you are using the AfterUpdate property (GoDawgs is correct if using BeforeUpdate, but this will also work there too...):

If Not Me![Text0] Like "*@*" Or Not Me![Text0] Like "*.*" Then
MsgBox ("Invalid e-mail address")
Me![somecontrol].SetFocus
Me![Text0].SetFocus
End If

and change the somefocus to any control except the Text0 and change the Text0 to the appropriate name...

****************************
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top