IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

IHM Discussion :

Trier une zone de liste par ordre décroissant de date


Sujet :

IHM

  1. #1
    Débutant
    Inscrit en
    Décembre 2007
    Messages
    1 235
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 1 235
    Points : 269
    Points
    269
    Par défaut Trier une zone de liste par ordre décroissant de date
    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:

    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
    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
    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
    Et je n'ai plus rien qui s'affiche dans ma zone de liste, je voudrais donc savoir ou est mon erreur??

    Merci

  2. #2
    Membre actif
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2008
    Messages
    221
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 221
    Points : 244
    Points
    244
    Par défaut
    Tu a mis deux order by :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    sql = sql & " ORDER BY tbl_Intervention.DateIntervention;"
     
    Me.lstResults.RowSource = sql & " order by tbl_Intervention.DateIntervention DESC"
    il y en a un de trop

  3. #3
    Débutant
    Inscrit en
    Décembre 2007
    Messages
    1 235
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 1 235
    Points : 269
    Points
    269
    Par défaut
    Sa marche merci

  4. #4
    Débutant
    Inscrit en
    Décembre 2007
    Messages
    1 235
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 1 235
    Points : 269
    Points
    269
    Par défaut
    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
    Public Sub RefreshQuery()
    Dim sql As String
    Dim SQLWhere As String
     
    sql = "SELECT tbl_DemandeDeCommande.ID_Demande, tbl_DemandeDeCommande.DateCommande as [Date de Commande], tbl_DemandeDeCommande.DélaiLivraisonPrévue as [Délai de livraison], tbl_Personnel.Identité, tbl_DemandeDeCommande.dateDemande as [Date de demande], tbl_Lignes.Designation as [Ligne], tbl_Machines.Designation as [Machine], tbl_Désignation.Désignation, tbl_Référence.Référence, tbl_DemandeDeCommande.Quantité, tbl_DemandeDeCommande.ID_Etat FROM (tbl_Lignes INNER JOIN tbl_Machines ON tbl_Lignes.[Id_Ligne] = tbl_Machines.[Id_Ligne]) INNER JOIN ((tbl_Désignation INNER JOIN tbl_Référence ON tbl_Désignation.[ID_Désignation] = tbl_Référence.[ID_Désignation]) INNER JOIN (tbl_Personnel INNER JOIN tbl_DemandeDeCommande ON tbl_Personnel.[ID_Personnel] = tbl_DemandeDeCommande.[ID_Emetteur]) ON tbl_Référence.[ID_Référence] = tbl_DemandeDeCommande.[ID_Référence]) ON tbl_Machines.[Id_Machine] = tbl_DemandeDeCommande.[ID_Machine] WHERE (((tbl_DemandeDeCommande.ID_Etat)=2))"
     
    If Not IsNull(Me.cmbRechLigne) Then
        sql = sql & " and tbl_Machines.Id_Ligne =  " & Me.cmbRechLigne & " "
    End If
     
    If Me.cmbRechMachine <> "" Then
        sql = sql & " and tbl_Machines.ID_Machine = " & Me.cmbRechMachine & " "
    End If
     
    If Me.cmbRechCat <> "" Then
        sql = sql & " and tbl_Désignation.ID_Catégorie =  " & Me.cmbRechCat & "  "
    End If
     
    If Me.listeEmetteur <> "" Then
        sql = sql & " and tbl_Personnel.ID_Personnel =  " & Me.listeEmetteur & "  "
    End If
     
    SQLWhere = Trim(Right(sql, Len(sql) - InStr(sql, "Where ") - Len("Where ") + 1))
     
    sql = sql & sql3 & ";"
     
    Me.lstResults.RowSource = sql & " order by tbl_DemandeDeCommande.DateCommande DESC"
    Me.lstResults.Requery
     
    End Sub
    Pour celui la même symptômes que précédemanet, mais je n'ai pas 2 fois un orderBy cette fois?

  5. #5
    Débutant
    Inscrit en
    Décembre 2007
    Messages
    1 235
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 1 235
    Points : 269
    Points
    269
    Par défaut
    Non c'est bon, c'est parce que j'avais un:

    Merci quand même!!!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Trier une zone de liste
    Par kamaxime dans le forum Access
    Réponses: 2
    Dernier message: 22/11/2006, 18h55
  2. Trier une zone de liste
    Par kamaxime dans le forum Access
    Réponses: 2
    Dernier message: 22/11/2006, 16h58
  3. Trier une zone de liste
    Par Shansson dans le forum Contribuez
    Réponses: 3
    Dernier message: 26/04/2006, 19h54
  4. Tri d'une zone de liste par bouton
    Par illight dans le forum Access
    Réponses: 7
    Dernier message: 09/11/2005, 19h39
  5. Trier une Zone de liste
    Par smicky77 dans le forum Access
    Réponses: 10
    Dernier message: 29/08/2005, 18h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo