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
I then set the search field validation rule to
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?