Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Run-query error

Hi,

I encountered an error while attempted to run a query in
a Excel-VBA subroutine to get data in a MDB database.
error reported as following:

Run time error'-2147217887'
You tried to execute a query that does not include the
specified expression 'Period' as part of an aggregate
function.

But I do have the field 'period', would somebody can help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Run-query error

John,
What's the SQL behind the query ?

NickHK

"JohnDing" wrote in message
...
Hi,

I encountered an error while attempted to run a query in
a Excel-VBA subroutine to get data in a MDB database.
error reported as following:

Run time error'-2147217887'
You tried to execute a query that does not include the
specified expression 'Period' as part of an aggregate
function.

But I do have the field 'period', would somebody can help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Run-query error

SQL = "SELECT Period, CDF_No, SAFE_No, Invoice_No,
Currency, Sum(Total_Amount) AS Total_Amount_Sum, Country
FROM EXPSALESDB GROUP BY Invoice_No HAVING ((Period ='" &
Period & "')) ORDER BY Invoice_No"

Thanks, Nick
-----Original Message-----
John,
What's the SQL behind the query ?

NickHK

"JohnDing" wrote in message
...
Hi,

I encountered an error while attempted to run a query

in
a Excel-VBA subroutine to get data in a MDB database.
error reported as following:

Run time error'-2147217887'
You tried to execute a query that does not include the
specified expression 'Period' as part of an aggregate
function.

But I do have the field 'period', would somebody can

help?


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Run-query error

"JohnDing" wrote ...

SQL = "SELECT Period, CDF_No, SAFE_No, Invoice_No,
Currency, Sum(Total_Amount) AS Total_Amount_Sum, Country
FROM EXPSALESDB GROUP BY Invoice_No HAVING ((Period ='" &
Period & "')) ORDER BY Invoice_No"


You would need to add to your GROUP BY cluse the columns in you SELECT
clause that are not being used in a set function (e.g. SUM) i.e. add
Period, CDF_No, SAFE_No, [Currency] to the GROUP BY clause. BTW I
think you need Currency in brackets because it is a reserved word in
Jet 4.0 (and is not very useful so consider renaming).

Jamie.

--
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
web query error Vijay Kotian Excel Discussion (Misc queries) 0 September 11th 07 10:22 AM
MS Query error Ken W Excel Worksheet Functions 1 April 6th 06 04:08 PM
MS query error Ken W Excel Discussion (Misc queries) 0 March 30th 06 01:37 PM
error using MS query Ken W Excel Discussion (Misc queries) 0 March 6th 06 03:47 AM
Web Query Run-time Error AG[_6_] Excel Programming 0 October 16th 04 02:17 AM


All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"