benjamin.grimm
Registered User.
- Local time
- Today, 14:21
- Joined
- Sep 3, 2013
- Messages
- 125
hello guys,
i have a cross table.
In the columns i have the months and in the rows i have country.
the cross table sums up in the specific months, how many busses will be build in the next 10 months.
So there wont be anything longer than one year. So the year does not matter.
Here my SQL Code for the cross table:
Now i want to sort the cross table.
Right now its:
xxxxxx Jan, Feb, Mrz, Apr, Mai .......
AT
BE
CH
DE
FR
.......
I want that it starts with the following months:
so like this (right now its march)
xxxxxxx Apr , Mai, Jun, Jul, Aug, .......
AT
BE
CH
DE
FR
.....
For this reason i created the querry: qsort
SQL code:
and with the follwing VBA i want to sort the querry then like i described before.
but it doesn´t work.
How can i change it ?
greetz benjamin
i have a cross table.
In the columns i have the months and in the rows i have country.
the cross table sums up in the specific months, how many busses will be build in the next 10 months.
So there wont be anything longer than one year. So the year does not matter.
Here my SQL Code for the cross table:
Code:
TRANSFORM Count([CC_400].where) AS AnzahlvonVerkaufsorg
SELECT [CC_400].[country], Count([CC_400].Verkaufsorg) AS [Gesamtsumme von Verkaufsorg]
FROM CC_400
GROUP BY [CC_400].[country]
PIVOT Format([Buildingdate],"mmm") In ("Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez");
Now i want to sort the cross table.
Right now its:
xxxxxx Jan, Feb, Mrz, Apr, Mai .......
AT
BE
CH
DE
FR
.......
I want that it starts with the following months:
so like this (right now its march)
xxxxxxx Apr , Mai, Jun, Jul, Aug, .......
AT
BE
CH
DE
FR
.....
For this reason i created the querry: qsort
SQL code:
Code:
SELECT Tabelle_months.ID, Tabelle_months.months, ([ID])-Month(Date())+IIf(Tabelle_months.ID-Month(Date())<=0,12,0) AS SortAuf
FROM Tabelle_months;
and with the follwing VBA i want to sort the querry then like i described before.
Code:
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim intPos As Integer
Dim strSort As String
Set rs = CurrentDb.OpenRecordset("QSort", dbReadOnly, dbForwardOnly)
Do Until rs.EOF
strSort = strSort & ",""" & rs(1) & """"
rs.MoveNext
Loop
strSort = "(" & Mid(strSort, 2) & ")"
Set qdf = CurrentDb.QueryDefs("CC_500_cross_table")
intPos = InStrRev(qdf.SQL, "In")
qdf.SQL = Left(qdf.SQL, intPos + 1) & strSort & ";"
rs.Close
qdf.Close
Set rs = Nothing
Set qdf = Nothing
Set db = Nothing
but it doesn´t work.
How can i change it ?
greetz benjamin