Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2003
    Posts
    46

    Unanswered: Validation rule - exclude Control Characters (& % ? etc.)???

    Hi out there,

    Banging my head against a wall again...VBA skills not that good...I'm trying to validate certain search fields on my form to make sure users do not type in any Control characters that will mess up the SQL statement that gets created when the user presses 'Search'. At the moment I have the following function (which is not working!):

    Public Function Characters(Mystring As String) As Integer
    Dim MyResult As Integer
    Dim searchstring As String
    Dim SearchChar As String

    searchstring = "(Mystring)" ' String to search in.
    SearchChar = "?" ' Search for "?".

    MyResult = InStr(searchstring, SearchChar)

    If MyResult > 0 Then
    Characters = False
    End If
    End Function

    I then set the search field validation rule to
    Characters([SearchField])=True

    Where am I going wrong (I suspect it's probably something blatantly obvious to anyone but me!! )?? Is this the best way to do it?

    Thanks a million
    C

  2. #2
    Join Date
    Aug 2002
    Posts
    31
    Your function is returning an integer.. try a boolean.

  3. #3
    Join Date
    Mar 2003
    Posts
    46
    Cheers Maia,

    tried

    Public Function Characters(Mystring As String) As Boolean

    but still no luck...

  4. #4
    Join Date
    Mar 2003
    Posts
    46
    will be offline now for a few hours but any additional suggestions gratefully received, will check back around 5pm
    Cheers
    C

  5. #5
    Join Date
    Aug 2002
    Posts
    31
    You need to set the value to true if you find the characters.. you are already setting to false if you don't...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •