[ODBC Excel Driver] Too few parameters.


New Member

I'm trying to create a query using the Microsoft Query Wizard that will query a table in another Excel Workbook. The command text that is generated by the Query Wizard is below. Works fine until I add a Where parameter (see below).

Command Text ("Tab" is the name of the worksheet containing the table I'm querying, in the source workbook I'm using):

SELECT `Tab$`.AssignDeptDesc, `Tab$`.BillingAreaInt, `Tab$`.Calc_Refer_Prov, `Tab$`.CC_Desc, `Tab$`.CC_Num, `Tab$`.ChgCorrFlag, `Tab$`.CountySum, `Tab$`.Dept_UniqPat, `Tab$`.DeptDesc, `Tab$`.FSCDesc, `Tab$`.Inv, `Tab$`.LOB, `Tab$`.PatientCityState, `Tab$`.PatientCountyDesc, `Tab$`.PatientID, `Tab$`.PatientZipCode, `Tab$`.PayerGroup, `Tab$`.ProviderDesc, `Tab$`.ProviderNum, `Tab$`.ProvType, `Tab$`.ReferProviderCityState, `Tab$`.ReferProviderDesc, `Tab$`.ReferProviderNPI, `Tab$`.ReferProviderNum, `Tab$`.ReferProviderZipCode, `Tab$`.RiskType, `Tab$`.RPCityState, `Tab$`.SLDept, `Tab$`.SvcDTInv, `Tab$`.SvcPd, `Tab$`.TotChgsInv
FROM `Tab$` `Tab$`

Where parameter:

WHERE `Tab$`.DeptDesc=?

The Enter Parameter Value window pops up, where I am choosing a particular cell on my excel worksheet, where I plan to put a data validation list of all DeptDesc values. Cell currently contains a valid DeptDesc value. I am choosing "Use this value/reference for future refreshes".

The error is receive is: [Microsoft][ODBC Excel Driver] Too few perameters. Expected 31.

31 is the number of fields in my query.

I have tried several variations of syntax in the where clause that I've seen online:

WHERE DeptDesc=?
WHERE `Tab$`.DeptDesc=?
WHERE (`Tab$`.DeptDesc=?)

All of them allow me to select the parameter value and then throw the above error.

This worked the first couple of times I tried it, without throwing any errors (using syntax: WHERE DeptDesc=?). I was able to change the value in my selected cell and refresh the query no problem.

One other thing I noticed: the query wizard was never able to see the actual table in my source workbook, and is always looking at the worksheet name instead. Is this a problem?

Any help would be greatly appreciated. Thanks!


MrExcel MVP
Re: [ODBC Excel Driver] Too few parameters. (yet another :)

hi, Luke

with 31 not found, it means the whole table is a problem. the query isn't connecting to the expected table.

Is one of these the problem : the source worksheet name has changed (from Tab), or the file/workbook name has changed (full file name including subdirectory)

if you re-create the query from scratch does it work?
If so, does that suit your needs. if not, what would?

regards, Fazza

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...