Neiko
September 25th, 2001, 12:07 PM
I have run into a problem. My application used to take ID codes like IT00087. I have changed it to accept 0000087. Now I'm running into some validation problems. For example, when I remove the following line,
Elseif IsNumeric(strStatement) then
Valid SQL = strStatement
The section that I was having problems with works, but it disables another section. When I step through both options, they both get to this point:
Public Function ValidSQL(ByVal strStatement as String) As String
Dim strOUT As String, strCur As String
Dim intMax As Long, intLVC As Long
'function handles potential dangerous character combinations in a string to be used as a value in an sql statement
'returns "NULL" or single-quoted padded string with valid character combinations for an sql statement
strOUT = vbNullString
If strStatement = vbNullString then
ValidSQL = "NULL"
ElseIf IsDate(strStatement) Then
Valid SQL = "#" & Format(DateValue(strStatement), "Short Date") & "#"
Elseif IsNumeric(strStatement) Then
Valid SQL = strStatement
Else
intMax = Len(strStatement)
For intLCV = 1 to intMax
strCur = Mid(strStatement, intLCV, 1)
If strCur = " ' " Then
strCur = " ' "
ElseIf strCur = " | " Then
strCur = vbNullString
End if
strOUT + strCur
Next
ValidSQL = " ' " & strOUT & " ' "
End if
End Function
I am fresh out of ideas with this one. Hopefully I've givin enough information so that someone can help me. Thanks so much
Elseif IsNumeric(strStatement) then
Valid SQL = strStatement
The section that I was having problems with works, but it disables another section. When I step through both options, they both get to this point:
Public Function ValidSQL(ByVal strStatement as String) As String
Dim strOUT As String, strCur As String
Dim intMax As Long, intLVC As Long
'function handles potential dangerous character combinations in a string to be used as a value in an sql statement
'returns "NULL" or single-quoted padded string with valid character combinations for an sql statement
strOUT = vbNullString
If strStatement = vbNullString then
ValidSQL = "NULL"
ElseIf IsDate(strStatement) Then
Valid SQL = "#" & Format(DateValue(strStatement), "Short Date") & "#"
Elseif IsNumeric(strStatement) Then
Valid SQL = strStatement
Else
intMax = Len(strStatement)
For intLCV = 1 to intMax
strCur = Mid(strStatement, intLCV, 1)
If strCur = " ' " Then
strCur = " ' "
ElseIf strCur = " | " Then
strCur = vbNullString
End if
strOUT + strCur
Next
ValidSQL = " ' " & strOUT & " ' "
End if
End Function
I am fresh out of ideas with this one. Hopefully I've givin enough information so that someone can help me. Thanks so much