PDA

View Full Version : Invalid procedure call or argument: 'Left'



lu lu
01-14-2004, 01:42 AM
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'Left' at the line:
strInList = Left(strInList, len(strInList)-1)

any ideas?

Dim arrCuisines, strInList

arrCuisines = array("AFRICAN","CARIBBEAN","CHINESE","CONTINENTAL",....")

For each cuisine In arrCuisines
If Request.Form(cuisine) = "true" Then
strInList = strInList & "'" & cuisine & "',"
End If
Next

strInList = Left(strInList, len(strInList)-1)

sql = "SELECT * FROM logbook WHERE cusine IN (" & strInList & ")"

bud
01-14-2004, 07:25 AM
This can happen if strInList is 0 characters in length...

If Len(strInList) > 1) Then
strInList = Left(strInList, len(strInList)-1)
End if

Idealy, I would check for physical location...

Mypos = InStrRev(strInList, ",")
If MyPos > 0 Then
strInList = Left(strInList, MyPos-len(strInList))
sql = "SELECT * FROM logbook WHERE cusine IN (" & strInList & ")"
Else 'There is no selection
sql = "SELECT * FROM logbook"
End If

You could look at using Trim to remove any unwanted spaces...

Dim MyVar
MyVar = LTrim(" vbscript ") ' MyVar contains "vbscript ".
MyVar = RTrim(" vbscript ") ' MyVar contains " vbscript".
MyVar = Trim(" vbscript ") ' MyVar contains "vbscript".