#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    24
    Rep Power
    0

    Email Validation


    am trying to validate an email field. i am putting this in the beforeupdate property of my field:

    If IsValidEmail(Me.Personal_Email.Value) Then
    MsgBox "Valid Email"
    Else
    MsgBox "Invalid Email"
    End If

    then, i am putting this in a module:

    Function IsValidEmail(strTextToCheck As String) As Boolean
    On Error GoTo ProcErr

    Dim bRetVal As Boolean

    'Trim spaces
    strTextToCheck = Trim(strTextToCheck)

    ' Check for single @ Symbol
    Dim lngPos As Long
    Dim strAtSign As String
    strAtSign = "@"
    lngPos = InStr(1, strTextToCheck, strAtSign, vbTextCompare)
    If lngPos > 0 Then ' Found @ sign. Now make sure it's the only one.
    lngPos = InStr(lngPos + Len(strAtSign), strTextToCheck, strAtSign, vbTextCompare)
    End If

    If lngPos = 0 Then
    bRetVal = False
    Else
    ' Check for blank space
    If InStr(1, strTextToCheck, Chr(32), vbTextCompare) Then
    bRetVal = False

    Else
    ' Check for top-level domain
    Select Case LCase(Right(strTextToCheck, 5))
    Case ".info": bRetVal = True
    Case Else
    Select Case LCase(Right(strTextToCheck, 4))
    Case ".com", ".net", ".biz", ".edu", ".org", ".mil": bRetVal = True
    Case Else
    Select Case LCase(Right(strTextToCheck, 3))
    Case ".tv", ".us", ".cc", ".bz": bRetVal = True
    Case Else: bRetVal = False
    End Select
    End Select
    End Select
    End If
    End If
    IsValidEmail = bRetVal

    ProcExit:
    Exit Function

    ProcErr:
    ShowErrorMessage ("IsValidEmail()")
    Resume ProcExit

    End Function


    When i run it, am getting message:

    Comile Error: Sub or Function not defined. this is referring to the line 'ShowErrorMessage ("IsValidEmail()")

    can someone please help?? thanks.

    ameen
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    Do you have this function defined in your project?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    24
    Rep Power
    0
    isn't it defined in

    Function IsValidEmail(strTextToCheck As String) As Boolean
    On Error GoTo ProcErr

    if i am missing something please tell me. i don't know much about this.
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    No, you are just calling the function/sub there. Where is the code for the actual function/sub in your project?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    24
    Rep Power
    0
    if it is not what is called in the beforeupdate property:

    If IsValidEmail(Me.Personal_Email.Value) Then
    MsgBox "Valid Email"
    Else
    MsgBox "Invalid Email"
    End If

    or not the code that i posted in the previous posts then i don't have it. what can i do?? i thought i just need code in the beforeupdate action and module. please help!

    ameen

IMN logo majestic logo threadwatch logo seochat tools logo