Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field verification

Status
Not open for further replies.

K3ith

Technical User
Oct 26, 2001
16
0
0
US
Can someone advise please, I am after achieving the following: I have a field whereby a user enters a name of a file, but what I want is some verification on the field (just like the validation windows uses) to call up a message box if any of the following characters are entered in the field, \/:*?”<>|. I understand it involves ASCII characters, but that is where my understanding stops.

Thanks in advance.

 
Assuming you are using at least A2K, this function will return NULL if the string is devoid of your special character list or, the first invalid character it finds. You can call it either in the after update event for that particular field or from the forms before update event.



'---------------------------------------------------------------------------------------
' Procedure : fStringError
' DateTime : 9/9/2002 16:37
' Author : bermanr
' Purpose : Returns an unacceptible character or null if OK
'---------------------------------------------------------------------------------------
'
Public Function fStringError(StringIn As String) As Variant
Dim sResult As String: sResult = &quot;&quot;
Dim ErrArray() As String
Dim intKnt As Integer
Dim intubound As Integer

On Error GoTo fStringError_Error

ErrArray = Split(&quot;\,/,*,?,>,<,|&quot;, &quot;,&quot;, -1)
intubound = UBound(ErrArray) - 1
For intKnt = 0 To intubound
If Nz(InStr(StringIn, ErrArray(intKnt))) > 0 Then
sResult = ErrArray(intKnt)
Exit For
End If
Next intKnt
fStringError = sResult

On Error GoTo 0
Exit Function

fStringError_Error:
MsgBox &quot;Error &quot; & Err.Number & &quot; (&quot; & Err.Description & &quot;) in procedure fStringError of Module Module1&quot;

End Function
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top