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.
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
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.