I have the following code. Can anyone tell me why it doesn't work? I have a table called myTable and there is one field called aField and only one value (of number type) under this field, which is 234.
Sub test()
myArrayAsAString = "123,456,789"
strSql = "Select * From myTable Where [aField] Not In ('"
For x = 0 To UBound(Split(myArrayAsAStr
ing, ","))
strSql = strSql & Split(myArrayAsAString, ",")(x) & "', '"
Next
strSql = Left(strSql, Len(strSql) - 3) & ")"
Debug.Print (strSql)
With CurrentDb.OpenRecordset(st
rSql)
Debug.Print .Fields(aField)
.Close
End With
End Sub
Start Free Trial