How to add VBA to a form field

  • Thread starter Thread starter venture
  • Start date Start date
V

venture

Guest
Hi Guys

I am trying to add some code to a form field to validate an e-mail address by seeing if it has an @ included. I found some code on here that looks as if it works but as I am new to vba in access I dont know how to attach it to the form field. I tried it using on exit and placing the code in the editor but it said my code was looping 20 times and exiting. Any ideas I am a newbie to access programming but have some experience in vba for excel and other prog languages.

Cheers :D

venture
 
why not try after update event.

You should post the code as there may be a problem with the code.

Ash
 
Thanks

Thanks Ash I will try that.
venture
 
The other way would be to set an input mask on that field so that it has to have the @ in it. That way the if the field is typed in incorrect the user will not be able to continue without fixing the field.

Probably easier then having code.

Ash
 
Here is a cheap way to verify a text string contains the @ and a . since a valid email address must look like xxx@123.com

Code:
Dim x As String
x = "xxx@123.com"

If x Like "*@*.*" Then
    MsgBox "True"
Else
    MsgBox "False"
End If
 

Users who are viewing this thread

Back
Top Bottom