Bonjour, je voudrais savoir comment trier une zone de liste par ordre décroissant de date.
Pour le moment le refreshQuery de ma zone de liste était le suivant:
J'ai remplacé par:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 Public Sub RefreshQuery() Dim sql, sqlCompteur As String Dim SQLWhere As String Dim dateFin, dateDébut As Date Dim oRst As DAO.Recordset Dim odb As DAO.Database Set odb = CurrentDb dateFin = "12/12/5000" dateDébut = "10/10/1901" sql = "SELECT tbl_Intervention.ID_Intervention, tbl_Intervention.DateIntervention as [Date d'Intervention], tbl_Machines.Designation AS Machine, tbl_Intervention.Descriptif FROM (tbl_Machines INNER JOIN tbl_Intervention ON tbl_Machines.[Id_Machine] = tbl_Intervention.[ID_Machine]) INNER JOIN tbl_Intervenir ON tbl_Intervention.ID_Intervention = tbl_Intervenir.ID_Intervention where (((tbl_Intervention.ID_Intervention)<>0)) " If Not IsNull(Me.listeRechLigne) Then sql = sql & " and tbl_Machines.Id_Ligne = " & Me.listeRechLigne & " " End If If Me.listeRechMachine <> "" Then sql = sql & " and tbl_Intervention.ID_Machine = " & Me.listeRechMachine & " " End If If Me.listeRechCat <> "" Then sql = sql & " and tbl_Intervention.ID_Catégorie = " & Me.listeRechCat & " " End If If Not IsNull(Me.txtDateDebut) Then dateDébut = Me.txtDateDebut.Value sql = sql & " AND ((tbl_Intervention.DateIntervention) Between #" & Format(dateDébut, "mm/dd/yyyy") & "# and #" & Format(dateFin, "mm/dd/yyyy") & "# )" End If If Not IsNull(Me.txtDateFin) Then dateFin = Me.txtDateFin sql = sql & " AND ((tbl_Intervention.DateIntervention) Between #" & Format(dateDébut, "mm/dd/yyyy") & "# and #" & Format(dateFin, "mm/dd/yyyy") & "# )" End If If Me.listeType <> "" Then sql = sql & " and tbl_Intervention.ID_Type = " & Me.listeType & " " End If If Me.listeEmetteur <> "" Then sql = sql & " and tbl_Intervenir.ID_Personnel = " & Me.listeEmetteur & " " End If sql = sql & " GROUP BY tbl_Intervention.ID_Intervention, tbl_Intervention.DateIntervention, tbl_Machines.Designation, tbl_Intervention.Descriptif" sqlCompteur = "select count(*) from (" & sql & ");" Set oRst = odb.OpenRecordset(sqlCompteur, dbOpenDynaset) Me.txtNombreLigneCritéres.Caption = oRst.Fields(0).Value sqlCompteur = "select count(*) from( select * from tbl_Intervention);" Set oRst = odb.OpenRecordset(sqlCompteur, dbOpenDynaset) Me.txtNombreLignetotal.Caption = oRst.Fields(0).Value SQLWhere = Trim(Right(sql, Len(sql) - InStr(sql, "Where ") - Len("Where ") + 1)) sql = sql & " ORDER BY tbl_Intervention.DateIntervention;" Me.lstResults.RowSource = sql Me.lstResults.Requery End Sub
Et je n'ai plus rien qui s'affiche dans ma zone de liste, je voudrais donc savoir ou est mon erreur??
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 Public Sub RefreshQuery() Dim sql, sqlCompteur As String Dim SQLWhere As String Dim dateFin, dateDébut As Date Dim oRst As DAO.Recordset Dim odb As DAO.Database Set odb = CurrentDb dateFin = "12/12/5000" dateDébut = "10/10/1901" sql = "SELECT tbl_Intervention.ID_Intervention, tbl_Intervention.DateIntervention as [Date d'Intervention], tbl_Machines.Designation AS Machine, tbl_Intervention.Descriptif FROM (tbl_Machines INNER JOIN tbl_Intervention ON tbl_Machines.[Id_Machine] = tbl_Intervention.[ID_Machine]) INNER JOIN tbl_Intervenir ON tbl_Intervention.ID_Intervention = tbl_Intervenir.ID_Intervention where (((tbl_Intervention.ID_Intervention)<>0)) " If Not IsNull(Me.listeRechLigne) Then sql = sql & " and tbl_Machines.Id_Ligne = " & Me.listeRechLigne & " " End If If Me.listeRechMachine <> "" Then sql = sql & " and tbl_Intervention.ID_Machine = " & Me.listeRechMachine & " " End If If Me.listeRechCat <> "" Then sql = sql & " and tbl_Intervention.ID_Catégorie = " & Me.listeRechCat & " " End If If Not IsNull(Me.txtDateDebut) Then dateDébut = Me.txtDateDebut.Value sql = sql & " AND ((tbl_Intervention.DateIntervention) Between #" & Format(dateDébut, "mm/dd/yyyy") & "# and #" & Format(dateFin, "mm/dd/yyyy") & "# )" End If If Not IsNull(Me.txtDateFin) Then dateFin = Me.txtDateFin sql = sql & " AND ((tbl_Intervention.DateIntervention) Between #" & Format(dateDébut, "mm/dd/yyyy") & "# and #" & Format(dateFin, "mm/dd/yyyy") & "# )" End If If Me.listeType <> "" Then sql = sql & " and tbl_Intervention.ID_Type = " & Me.listeType & " " End If If Me.listeEmetteur <> "" Then sql = sql & " and tbl_Intervenir.ID_Personnel = " & Me.listeEmetteur & " " End If sql = sql & " GROUP BY tbl_Intervention.ID_Intervention, tbl_Intervention.DateIntervention, tbl_Machines.Designation, tbl_Intervention.Descriptif" sqlCompteur = "select count(*) from (" & sql & ");" Set oRst = odb.OpenRecordset(sqlCompteur, dbOpenDynaset) Me.txtNombreLigneCritéres.Caption = oRst.Fields(0).Value sqlCompteur = "select count(*) from( select * from tbl_Intervention);" Set oRst = odb.OpenRecordset(sqlCompteur, dbOpenDynaset) Me.txtNombreLignetotal.Caption = oRst.Fields(0).Value SQLWhere = Trim(Right(sql, Len(sql) - InStr(sql, "Where ") - Len("Where ") + 1)) sql = sql & " ORDER BY tbl_Intervention.DateIntervention;" Me.lstResults.RowSource = sql & " order by tbl_Intervention.DateIntervention DESC" Me.lstResults.Requery End Sub
Merci
Partager