Invalid Column error message

scott1742

New Member
Joined
Aug 19, 2011
Messages
3
I have MS Excel 2010 and am receiving an error message with the following sql query within MSquery...

SELECT invoice_line.item_id, Count(invoice_line.line_no) AS 'units', Sum(invoice_line.qty_shipped) AS 'Sum of qty_shipped'
FROM Prophet21_12_Live.dbo.invoice_hdr invoice_hdr, Prophet21_12_Live.dbo.invoice_line invoice_line
WHERE invoice_line.invoice_no = invoice_hdr.invoice_no
GROUP BY invoice_line.item_id, invoice_hdr.period, invoice_hdr.year_for_period
HAVING (invoice_line.item_id Between 'ap labor 021' And 'ap labor wa') AND (invoice_hdr.period=[enter period]) AND (invoice_hdr.year_for_period=[enter year])
ORDER BY invoice_line.item_id

Error is
'Invalid Column Name' enter period
'Invalid Column Name' enter year
Statesment(s) could not be prepared.

I can enter values in for the year and period and get data.
I can enter other queries using [] for input data and it works.

The error is stumping me.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I found out one thing. If I remove the sum and the count functions, the parameter box will work, and if I add the sum or count function, the parameter box will not work. Any ideas?
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,728
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top