hi,
I am stuck in a problem since one week and need help!!!
I am running a SQL query in Excel 2010 VBA. The query runs fine but when I use GROUP BY, I get Automation Error.
Everything works if I remove Group By but I need to group data.
My query looks like:
Dim objRs As New ADODB.Recordset
Dim output As String
Dim trows As Integer
Dim ThisTab As Excel.Worksheet
Dim tcols As Integer
Dim i As Integer
Dim sSQL As String
' sSQL = "SELECT * from [Data] where [Rem Scen 2] > 0 and (Now() - [Eval Date]) <=60"
sSQL = "SELECT [Emp ID], [Deptt], [Job Types], [Join Date],[Pay 1]+[Pay 2] as [Compensate] from [Data] Group By {Emp ID]
With objConn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & ";" & _
"Extended Properties=""Excel 12.0 Macro;HDR=YES"";"
.Open
End With
' Execute once and display...
objRs.Open sSQL, objConn
Solved by F. E. in 30 mins