下面的代码给出了错误"没有给出一个或多个参数的值"并停在该行:rs.open qry,cn
但是,如果执行当前已注释掉的其他qry(SELECT * FROM CallData),则代码运行没有任何问题。
我需要做什么修改才能使代码能够使用GROUP BY Query正确运行?
Dim cn As Object Dim rs As Object Dim qry As String Dim Insertws As Worksheet Dim strConnectString As String Set Insertws = ThisWorkbook.Sheets("temp") Insertws.Cells.Clear strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\corpfiler09\26663700_N01\NewAstt\ASTT.MDB;Jet OLEDB:Database Password=test;" 'Connect Database; insert a new table Set cn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") 'qry = "SELECT * FROM CallData;" qry = "SELECT Bank, Count(Bank) from CallData where TicketDate = Date GROUP BY Bank"cn.Open strConnectString rs.Open qry, cn
答案 0 :(得分:0)
我会写这样的查询:
SELECT CallData.Bank, Count(CallData.Bank) AS CountOfBank
FROM CallData
GROUP BY CallData.Bank, CallData.TicketDate
HAVING (((CallData.TicketDate)=Date()));