Too Few Parameters Expected N

If you’re working with ActiveX Data Objects (ADO) and connecting to a Jet database, you may get this error. One possible cause is that you misspelled a column name. When Jet encounters an unrecognized column name, it assumes it’s a parameter. Check the spelling of the field names in your SELECT statement.

Another possible cause, and one I experienced today, is surrounding strings in your WHERE clause with double quotes – it needs to be single quotes. Mine was fairly easy to track down because the error was “Too Few Parameters, Expected 3?. My SELECT statement started like this: SELECT * FROM salesorder... so I knew I hadn’t spelled any column names wrong. I also knew I had five variables in my WHERE clause; three Strings and two Dates. I figured the problem must be in the Strings and it was.

sWhere = sWhere & ” (CustomerRef_ListID='” & gsREPAIRCUSTID & “‘)”
Posted in Uncategorized

5 thoughts on “Too Few Parameters Expected N

  1. Yeah…I had something like this a couple of years back. I was trying to connect to an Access database via VBA. I posted the problem in the excel.programming newsgroup and those that responded at that time were stumped as well. I think I picked it up through trial and error.

  2. I have long since just got into the habit of WHERE(((stringField)=” & PadQuotes(myStringValue) & “));”

    Public Function PadQuotes(ByVal szBareString As String) As String

        PadQuotes = Chr(34) & szBareString & Chr(34)

    End Function

  3. As Doco shows it doesn’t really matter what the quotes are single or double. I prefer single to make it easier to read in vba, but the worst of all are irish names. They always catch me out.

Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.