GFullington
Programmer
TRIED A PIVOT TABLE, BUT ADDS TOTALS AND DISPLAYS THE COLUMNS HORIZONTALLY.
IN ESSENCE, i WANT THE ROWS TO BE VERTICAL INSTEAD OF HORIZONTAL.
IN ESSENCE, i WANT THE ROWS TO BE VERTICAL INSTEAD OF HORIZONTAL.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SELECT CustID, InvoicePeriod, "Balance" as Item,[Balance] as Amt
FROM tblWithNoName
UNION ALL
SELECT CustID, InvoicePeriod, "CAP",[CAP]
FROM tblWithNoName
UNION ALL
SELECT CustID, InvoicePeriod, "BilledAmt",[BilledAmt]
FROM tblWithNoName;
TRANSFORM Sum(Amt) AS SumOfAmt
SELECT CustID, Item
FROM qselFullington
GROUP BY CustID, Item
PIVOT InvoicePeriod;
Public Function CreateXTBQueryFullington()
Dim strSQL As String
Dim strColumnHeadings As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
strSQL = "SELECT DISTINCT InvoicePeriod FROM qselFullington ORDER BY InvoicePeriod DESC"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
With rs
.MoveFirst
Do Until .EOF
strColumnHeadings = strColumnHeadings & rs(0) & ","
.MoveNext
Loop
.Close
End With
Set rs = Nothing
'get rid of the last ","
strColumnHeadings = Left(strColumnHeadings, Len(strColumnHeadings) - 1)
strSQL = "TRANSFORM Sum(qselFullington.Amt) AS SumOfAmt " & _
"SELECT qselFullington.CustID, qselFullington.Item " & _
"from qselFullington " & _
"GROUP BY qselFullington.CustID, qselFullington.Item " & _
"PIVOT qselFullington.InvoicePeriod " & _
" IN (" & strColumnHeadings & ");"
db.QueryDefs("qxtbFullington").SQL = strSQL
Set db = Nothing
End Function