G
gatarossi
Dear all,
Is it possible to bring the heading information in this query?
Sub return_data_byDept()
Dim adoconn As ADODB.Connection
Dim adors As ADODB.Recordset
Dim sql As String
Dim filenm As String
Dim xlsht As Excel.Worksheet
Set xlsht = Sheets("db by Dept")
filenm = ThisWorkbook.Path & "\bd_lg_expenses.mdb"
Application.ScreenUpdating = False
'xlsht.Visible = xlSheetVisible
xlsht.Select
xlsht.Range(Cells(1, 1), Cells(65536, 256)).ClearContents
sql = "TRANSFORM Sum(tbl_by_dept.amt) AS SomaDeamt "
sql = sql & "SELECT Right([acct_cd],6) AS acct_code "
sql = sql & "FROM tbl_by_dept "
sql = sql & "GROUP BY Right([acct_cd],6) "
sql = sql & "PIVOT tbl_by_dept.month ;"
Call getCn(adoconn, adors, sql, filenm, "", "")
xlsht.Cells(1, 1).CopyFromRecordset adors
'xlsht.Visible = xlSheetVeryHidden
Sheets("by Dept").Select
Application.ScreenUpdating = True
adors.Close
adoconn.Close
Set adors = Nothing
Set adoconn = Nothing
Set xlsht = Nothing
End Sub
Thanks in advance!
André.
Is it possible to bring the heading information in this query?
Sub return_data_byDept()
Dim adoconn As ADODB.Connection
Dim adors As ADODB.Recordset
Dim sql As String
Dim filenm As String
Dim xlsht As Excel.Worksheet
Set xlsht = Sheets("db by Dept")
filenm = ThisWorkbook.Path & "\bd_lg_expenses.mdb"
Application.ScreenUpdating = False
'xlsht.Visible = xlSheetVisible
xlsht.Select
xlsht.Range(Cells(1, 1), Cells(65536, 256)).ClearContents
sql = "TRANSFORM Sum(tbl_by_dept.amt) AS SomaDeamt "
sql = sql & "SELECT Right([acct_cd],6) AS acct_code "
sql = sql & "FROM tbl_by_dept "
sql = sql & "GROUP BY Right([acct_cd],6) "
sql = sql & "PIVOT tbl_by_dept.month ;"
Call getCn(adoconn, adors, sql, filenm, "", "")
xlsht.Cells(1, 1).CopyFromRecordset adors
'xlsht.Visible = xlSheetVeryHidden
Sheets("by Dept").Select
Application.ScreenUpdating = True
adors.Close
adoconn.Close
Set adors = Nothing
Set adoconn = Nothing
Set xlsht = Nothing
End Sub
Thanks in advance!
André.