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

Access Discussion :

Recherche multi-critères


Sujet :

Access

  1. #21
    Expert éminent sénior

    Avatar de Tofalu
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Octobre 2004
    Messages
    9 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Octobre 2004
    Messages : 9 501
    Points : 32 311
    Points
    32 311
    Par défaut
    Citation Envoyé par moi
    Tu as essayé de debuguer ? Que vaut SQL à la fin ?
    Si tu n'essaye pas de debuguer et de connaitre la valeur de la variable SQL autant abandonné tout de suite

  2. #22
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    en effet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    If Me.chkDC Then 
       SQL = SQL & "And Patients![DC] " & ";" 
    End If 
     
    SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
    j'ai encore un code erreur 3075

  3. #23
    Membre expérimenté

    Profil pro
    Inscrit en
    Juin 2003
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Localisation : Sénégal

    Informations forums :
    Inscription : Juin 2003
    Messages : 1 229
    Points : 1 579
    Points
    1 579
    Par défaut
    Citation Envoyé par PAUL87
    en effet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    If Me.chkDC Then 
       SQL = SQL & "And Patients![DC] " & ";" 
    End If
    j'ai encore un code erreur 3075
    Normal le And est incomplét

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    If Me.chkDC Then 
       SQL = SQL & "And Patients![DC]=me.chkDC  ";" 
    End If
    Amicalement

  4. #24
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    Merci de votre aide parceque je nage

    erreur de compilation : erreur de syntaxe dans
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SQL = SQL & "And Patients![DC]=me.chkDC  ";"

  5. #25
    Expert éminent sénior

    Avatar de Tofalu
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Octobre 2004
    Messages
    9 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Octobre 2004
    Messages : 9 501
    Points : 32 311
    Points
    32 311
    Par défaut
    Et l'opérateur de concaténation ?

  6. #26
    Membre éprouvé
    Avatar de keita
    Homme Profil pro
    Inscrit en
    Novembre 2002
    Messages
    881
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Novembre 2002
    Messages : 881
    Points : 1 121
    Points
    1 121
    Par défaut
    d'accord mets ça:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SQL = SQL & "And Patients![DC]=True;"
    Attention ici:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1)) 
    SQL = SQL & SQLOrder & ";"
    tu enleves la derniere ligne;donc comme ça:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
    @+

  7. #27
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    comme ça c'est mieux??
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SQL = SQL & "And Patients![DC]= '" & Me.chkDC & ";"

  8. #28
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    oups nos réponses se sont croisees visiblement la mienne n'était pas bonne.

  9. #29
    Membre éprouvé
    Avatar de keita
    Homme Profil pro
    Inscrit en
    Novembre 2002
    Messages
    881
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Novembre 2002
    Messages : 881
    Points : 1 121
    Points
    1 121
    Par défaut
    as tu essayé ma solution?

  10. #30
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    oui bien sur
    Alors là j'ai une erreur dans
    Private Sub RefreshQuery()

  11. #31
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    j'en suis la:
    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
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
     
    Private Sub chkDC_Click()
       RefreshQuery
    End Sub
     
    Private Sub chkNomEtude_Click()
     
    If Me.chkNomEtude Then
        Me.cmbRechNomEtude.Visible = False
    Else
        Me.cmbRechNomEtude.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub chkNomInvestigateur_Click()
     
    If Me.chkNomInvestigateur Then
        Me.cmbRechNomInvestigateur.Visible = False
    Else
        Me.cmbRechNomInvestigateur.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
     
    Private Sub chkTYPEDEPATHOLOGIE_Click()
     
    If Me.chkTYPEDEPATHOLOGIE Then
        Me.cmbRechTYPEDEPATHOLOGIE.Visible = False
    Else
        Me.cmbRechTYPEDEPATHOLOGIE.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub cmbRechNomEtude_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub cmbRechNomInvestigateur_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub cmbRechTYPEDEPATHOLOGIE_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub Form_Load()
     
    Dim ctl As Control
     
    For Each ctl In Me.Controls
        Select Case Left(ctl.Name, 3)
            Case "chk"
                ctl.Value = -1
     
            Case "lbl"
                ctl.Caption = "- * - * -"
     
            Case "txt"
                ctl.Visible = False
                ctl.Value = ""
     
            Case "cmb"
                ctl.Visible = False
     
        End Select
    Next ctl
     
    Me.lstResults.RowSource = "SELECT Reclin, NOM,PRENOM, NOMETUDE, NOMINVESTIGATEUR, TYPEDEPATHOLOGIE, DC FROM Patients;"
    Me.lstResults.Requery
     
    End Sub
    Private Sub RefreshQuery()
     
    Dim SQL As String
    Dim SQLWhere As String
     
    SQL = "SELECT Reclin, NOM, PRENOM, NOMETUDE, NOMINVESTIGATEUR, TYPEDEPATHOLOGIE, DC FROM Patients Where Patients!Reclin <> 0 "
     
     
     
    If Not Me.chkNomEtude Then
        If Len(chkNomEtude) > 0 Then
        SQL = SQL & "And Patients!NomEtude = '" & Me.cmbRechNomEtude & "' "
        End If
    End If
     
    If Not Me.chkNomInvestigateur Then
        If Len(chkNomInvestigateur) > 0 Then
        SQL = SQL & "And Patients!NomInvestigateur = '" & Me.cmbRechNomInvestigateur & "' "
        End If
    End If
     
     
    If Not Me.chkTYPEDEPATHOLOGIE Then
        If Len(chkTYPEDEPATHOLOGIE) > 0 Then
        SQL = SQL & "And Patients!TYPEDEPATHOLOGIE = '" & Me.cmbRechTYPEDEPATHOLOGIE & "' "
        End If
    End If
     
    If Me.chkDC Then
      SQL = SQL & "And Patients![DC]=True;"
    End If
     
    SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
     
     
     
    Me.lblStats.Caption = DCount("*", "Patients", SQLWhere) & " / " & DCount("*", "Patients")
    Me.lstResults.RowSource = SQL
    Me.lstResults.Requery
     
     
    Dim Nbtotal, Resul As Integer
     
    Nbtotal = DCount("*", "Patients")
    Resul = DCount("*", "Patients", SQLWhere)
    Me.Texte50 = (Resul / Nbtotal) * 100
    End Sub

  12. #32
    Membre éprouvé
    Avatar de keita
    Homme Profil pro
    Inscrit en
    Novembre 2002
    Messages
    881
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Novembre 2002
    Messages : 881
    Points : 1 121
    Points
    1 121
    Par défaut
    et toujours "erreur de syntaxe"?

  13. #33
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    maintenant
    erreur de compilation,
    membre de methode ou de donnees introuvables
    avec en surligné
    "if Me.chkDC Then"

  14. #34
    Expert éminent sénior

    Avatar de Tofalu
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Octobre 2004
    Messages
    9 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Octobre 2004
    Messages : 9 501
    Points : 32 311
    Points
    32 311
    Par défaut
    Es tu sur du nom de la case à coché ?

    J'ai plutot l'impression que tu nous balances ton code sans essayer de faire trop d'effort ... C'est pas vraiment la politique de la maison

  15. #35
    Membre éprouvé
    Avatar de keita
    Homme Profil pro
    Inscrit en
    Novembre 2002
    Messages
    881
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Novembre 2002
    Messages : 881
    Points : 1 121
    Points
    1 121
    Par défaut
    Beh, PAUL,sans vraiment vouloir te vexer, mais la remarque faite par Tofalu me semble appropriée;parce que cette erreur aurait du etre apparaitre depuis longtemps.
    essai ça pour voir:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    If Me!chkDC.value=true Then
    @+

  16. #36
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    Je ne suis pas totalement d'accord avec votre sévérité a mon egard....
    je suis d'un naturel tenace
    je trouve cette recherche multi-critère particulièrement ardue (pour mon niveau) et dois vous avouer que je suis plus qu'en difficulté avec.
    Si je "balance mon code" c'est parce qu'entre chaque post, j'essaye d'y faire des modifs..
    N'étant pas un ancien du Forum, je n'en connais pas moins la politique..
    Merci du rappel à l'ordre
    il me reste néanmois un message d'erreur pour lequel j'ai besoin d'aide..
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Me.lblStats.Caption = DCount("*", "Patients", SQLWhere) & " / " & DCount("*", "Patients")

  17. #37
    Expert éminent sénior

    Avatar de Tofalu
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Octobre 2004
    Messages
    9 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Octobre 2004
    Messages : 9 501
    Points : 32 311
    Points
    32 311
    Par défaut
    Quel est le message d'erreur ?

  18. #38
    Membre éprouvé
    Avatar de keita
    Homme Profil pro
    Inscrit en
    Novembre 2002
    Messages
    881
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Novembre 2002
    Messages : 881
    Points : 1 121
    Points
    1 121
    Par défaut
    En attendant ton message d'erreur, isole cette partie:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Me.lblStats.Caption = DCount("*", "Patients", SQLWhere) & " / " & DCount("*", "Patients")
    en mettant des appostrophes devant chaque ligne et essaie d'executer si tout se passe bien sans bien entendu les stat que tu attends.
    @+

  19. #39
    Membre régulier
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    388
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 388
    Points : 72
    Points
    72
    Par défaut
    j'ai un message " erreur d'exécution 3075"
    erreur de syntaxe dans l'expression 'patients!reclin<>0and patient!nominvestigateurs=" and patients![DC]=true;'

  20. #40
    Membre éprouvé
    Avatar de keita
    Homme Profil pro
    Inscrit en
    Novembre 2002
    Messages
    881
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations forums :
    Inscription : Novembre 2002
    Messages : 881
    Points : 1 121
    Points
    1 121
    Par défaut
    ok Paul, fais ça:
    le code actuellement:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    If Me.chkDC Then 
      SQL = SQL & "And Patients![DC]=True;" 
    End If
    mets un espace avant le "And", comme ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    If Me.chkDC Then 
      SQL = SQL & " And Patients![DC]=True;" 
    End If
    Juste avant le "And"
    @+

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 4 PremièrePremière 1234 DernièreDernière

Discussions similaires

  1. Recherche multi-critères
    Par AzAiEz dans le forum Access
    Réponses: 4
    Dernier message: 13/01/2006, 17h05
  2. [MySQL] Recherche multi-critères ou un seul
    Par jack1234 dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 14/12/2005, 08h56
  3. problème SQL avec le tutoriel recherche multi critère
    Par qbihlmaier dans le forum Requêtes et SQL.
    Réponses: 1
    Dernier message: 05/12/2005, 19h33
  4. problème avec résultat de recherche multi-critères
    Par audrey_desgres dans le forum Access
    Réponses: 2
    Dernier message: 23/06/2005, 11h00
  5. Procédure stockée: recherche multi-critères
    Par biroule dans le forum MS SQL Server
    Réponses: 11
    Dernier message: 01/09/2004, 16h02

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