lukegtempleton
New Member
- Joined
- Jul 18, 2017
- Messages
- 2
Hello,
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!
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!