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

Validating Email Addresses

Status
Not open for further replies.

MarkWaddington

Programmer
Aug 19, 2002
64
GB
Ok, I know this is probably simple, but what is the condition I would need to put in a macro in order to check that all entries in an "email" box on my form contain the "@" symbol?

Cheers,

Mark Waddington.
 
An easier test might be:

IF Instr(Me!EMAIL,"@") = 0 then
Msgbox "Invalid Email address ...", vbOKOnly
ME!Email.SetFocus
Me!Email.Value = Null
Else
EndIF

Not sure why it didn't work the way you have it, but it may be due to the MsgBox being AFTER the Setfocus method.

Think about your order of events -

1) is there an error?
2) if yes, put up a message box
3) Bounce back to the field in error
4) Null it out

Your statements were in exactly the opposite sequence.

Jim
Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Thanks for the reply.

I tried it both ways round, the SetFocus command just doesn't work! It still tabs to the next field along.

Anymore clues?
 
I know this is an old (ish) thread, but I am having exactly the same problem. I have tried everything - moving the code to the before update event and taking out the SetFocus method, but even then, after you click OK in the message box the focus still flips to the next field. I have tried putting in an OK/Cancel message box and it still happens no matter which button you click. I'm at my wits end!!!

Mark - did you ever get this problem sorted?
 
Hi,

I had this problem with the SetFocus method & found if I first SetFocus to another control & then back to the one I wanted it got round it.

Sharon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top