I'm probably missing something really obvious, but I can't see it!!!
I have an email address field in a form. When the user exits the text box, I need an emailaddresscheck function to be run.
Here is the function:
Public Function EmailAddCheck()
Dim blnValid As Boolean
blnValid = True
If Len(EmailAddress.Text) < 6 Then blnValid = False
'checks that e-mail address is more than 6 characters
If InStr(EmailAddress.Text, "@") = 0 Then blnValid = False
'checks for @ in EmailAddressAddress address
If InStr(EmailAddress.Text, ".") = 0 Then blnValid = False
'checks for . in EmailAddress address
If Left(EmailAddress.Text, 1) = "@" Then blnValid = False
'checks that there is a name before the @ sign
If Right(EmailAddress.Text, 1) = "." Then blnValid = False
'checks that there is a destination code in the e-mail address after .
If Not blnValid Then
Cancel = True
'if all appear, then cancel
MsgBox "Invalid Email address, please re-enter."
'if one or more do not appear, display msgbox
End If
End Function
I have then put on the text box exit:
Private Sub EmailAddress_Exit(Cancel As Integer)
Run EmailAddCheck
End Sub
Can anyone please tell me why this does not run?
Thanks
I have an email address field in a form. When the user exits the text box, I need an emailaddresscheck function to be run.
Here is the function:
Public Function EmailAddCheck()
Dim blnValid As Boolean
blnValid = True
If Len(EmailAddress.Text) < 6 Then blnValid = False
'checks that e-mail address is more than 6 characters
If InStr(EmailAddress.Text, "@") = 0 Then blnValid = False
'checks for @ in EmailAddressAddress address
If InStr(EmailAddress.Text, ".") = 0 Then blnValid = False
'checks for . in EmailAddress address
If Left(EmailAddress.Text, 1) = "@" Then blnValid = False
'checks that there is a name before the @ sign
If Right(EmailAddress.Text, 1) = "." Then blnValid = False
'checks that there is a destination code in the e-mail address after .
If Not blnValid Then
Cancel = True
'if all appear, then cancel
MsgBox "Invalid Email address, please re-enter."
'if one or more do not appear, display msgbox
End If
End Function
I have then put on the text box exit:
Private Sub EmailAddress_Exit(Cancel As Integer)
Run EmailAddCheck
End Sub
Can anyone please tell me why this does not run?
Thanks