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 :

lstresults formulaire recherche multicritères


Sujet :

IHM

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut lstresults formulaire recherche multicritères
    Bonjour,
    débutant sur Access, je me suis lancé dans la réalisation d'une bdd sous Access 2003 pour le suivi des bons de commande.
    j'ai adapté le tutoriel de caféine pour réaliser un formulaire de recherche sur les champs NumBon, Date et Fournisseur de ma table (tblboncommande).
    la table est organisée de la manière suivante :
    RefBon : Numéro auto
    NumBon : Numérique
    Date : Date/Heure
    Fournisseur : Texte
    lorsque j'ouvre le formulaire, tout semble OK.
    par contre lorsque je clique sur les cases à cocher, plus rien ne se passe : le formulaire semble bloqué.

    ci dessous le code :

    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
     
    Private Sub chkDate_Click()
        Me.txtRechDate.Visible = Not Me.txtRechDate.Visible
     
    End Sub
     
    Private Sub chkFourn_Click()
     
        Me.cmbRechFourn.Visible = Not Me.cmbRechFourn.Visible
     
        RefreshQuery
     
    End Sub
     
    Private Sub chkNum_Click()
        Me.txtRechNum.Visible = Not Me.txtRechNum.Visible
        RefreshQuery
     
    End Sub
     
    Private Sub cmbRechFourn_BeforeUpdate(Cancel As Integer)
        RefreshQuery
    End Sub
     
    Private Sub lstResults_DblClick(Cancel As Integer)
        DoCmd.OpenForm "frmAutoBon", acNormal, , "[RefBon]=" & Me.lstResults
     
    End Sub
     
    Private Sub txtRechDate_BeforeUpdate(Cancel As Integer)
        RefreshQuery
    End Sub
     
    Private Sub txtRechNum_BeforeUpdate(Cancel As Integer)
        RefreshQuery
    End Sub
     
    Private Sub RefreshQuery()
        Dim SQL As String
        Dim SQLWhere As String
     
        SQL = "SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 "
        If Me.chknum Then
            SQL = SQL & "And tblboncommande!NumBon = " & Me.txtRechNum
        End If
        If Me.chkDate Then
            SQL = SQL & "And tblboncommande!Date = #" & Format(Me.txtRechDate, "mm/dd/yyy") & "#)"
        End If
        If Me.chkFourn Then
            SQL = SQL & "And tblboncommande!Fournisseur = '" & Me.cmbRechFourn & "'"
        End If
     
        SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
        SQL = SQL & ";"
     
        Debug.Print SQL
     
        Me.lblStats.Caption = DCount("*", "tblboncommande", SQLWhere) & "/" & DCount("*", "tblboncommande")
        Me.lstResults.RowSource = SQL
        Me.lstResults.Requery
     
    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 RefBon, NumBon, Date, Fournisseur FROM tblboncommande;"
    Me.lstResults.Requery
     
    End Sub

    Merci d'avance pour votre aide.

    PS : je débute également sur ce site. n'hésitez donc pas à me dire s'il manque des infos ou si elles ne sont pas mentionnées correctement.

  2. #2
    Expert éminent
    Avatar de cafeine
    Inscrit en
    Juin 2002
    Messages
    3 904
    Détails du profil
    Informations forums :
    Inscription : Juin 2002
    Messages : 3 904
    Points : 6 781
    Points
    6 781
    Par défaut
    Hello,

    que donne Debug.Print SQL ?

    Pour plus d'info sur le débogage, tu peux lire ce tuto :
    http://cafeine.developpez.com/access...el/debugprint/
    Ne mettez pas "Problème" dans vos titres, par définition derrière toute question se cache un problème
    12 tutoriels Access



  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    j'étais justement en train de regarder de ce coté.

    et ca donne ca :

    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 And tblboncommande!Date = ##)And tblboncommande!Fournisseur = '';
    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 And tblboncommande!NumBon = And tblboncommande!Date = ##)And tblboncommande!Fournisseur = '';
    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 And tblboncommande!NumBon = And tblboncommande!Date = ##);
    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 And tblboncommande!NumBon = And tblboncommande!Date = ##)And tblboncommande!Fournisseur = '';
    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 And tblboncommande!NumBon = And tblboncommande!Fournisseur = '';

  4. #4
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    Bon, je viens de reprendre entièrement le code depuis le début. j'ai également vérifié les formats des champs de la table et des txtbox. mais je crois visiblement que je dois faire toujours la même erreur.

    si qqun a une idée pour me sortir de là.


    le debug.print SQL donne le message suivant :

    SELECT [RefBon],[NumBon],[Date],[Fournisseur] FROM [tblboncommande] Where [tblboncommande]![RefBon] <> 0 AND [tblboncommande]![NumBon]=''AND [tblboncommande]![Fournisseur]='';

    SELECT [RefBon],[NumBon],[Date],[Fournisseur] FROM [tblboncommande] Where [tblboncommande]![RefBon] <> 0 AND [tblboncommande]![NumBon]=''AND [tblboncommande]![Fournisseur]='';

    SELECT [RefBon],[NumBon],[Date],[Fournisseur] FROM [tblboncommande] Where [tblboncommande]![RefBon] <> 0 AND [tblboncommande]![Date]=##AND [tblboncommande]![Fournisseur]='';

  5. #5
    Expert éminent
    Avatar de cafeine
    Inscrit en
    Juin 2002
    Messages
    3 904
    Détails du profil
    Informations forums :
    Inscription : Juin 2002
    Messages : 3 904
    Points : 6 781
    Points
    6 781
    Par défaut
    Visiblement, il ne reprend aucune valeur de tes contrôles ...

    1- Teste les : Me.txtRechNum avec un MsgBox ou bien un debug.print
    2- ajoute un espace :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Sql = Sql & " And ......"
    au lieu de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Sql = Sql & "And ......"
    Ne mettez pas "Problème" dans vos titres, par définition derrière toute question se cache un problème
    12 tutoriels Access



  6. #6
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    je vais bien finir par y arriver

    maintenant ca marche pour le cmbRechFourn (format texte).
    par contre cela m'indique une erreur de syntaxe (Erreur d'exécution 3075) pour le txtRechNum (Numérique) et pour le txtRechDate (date/heure) au moment ou je clique sur le chk (chkNum et chkDate).

    le code est 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
    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
     
    Private Sub chkDate_Click()
     
    If Me.chkDate Then
        Me.txtRechDate.Visible = False
    Else
        Me.txtRechDate.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub chkFourn_Click()
     
    If Me.chkFourn Then
        Me.cmbRechFourn.Visible = False
    Else
        Me.cmbRechFourn.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub chkNum_Click()
     
    If Me.chknum Then
        Me.txtRechNum.Visible = False
    Else
        Me.txtRechNum.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub cmbRechFourn_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub lstResults_DblClick(Cancel As Integer)
        DoCmd.OpenForm "frmAutoBon", acNormal, , "[RefBon]=" & Me.lstResults
     
    End Sub
     
    Private Sub txtRechDate_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub txtRechNum_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub RefreshQuery()
    Dim SQL As String
    Dim SQLWhere As String
     
    SQL = "SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 "
     
    If Not Me.chknum Then
        SQL = SQL & "And tblboncommande!NumBon = " & Me.txtRechNum
    End If
    If Not Me.chkDate Then
        SQL = SQL & "And tblboncommande!Date = #" & Format(Me.txtRechDate, "mm/dd/yyyy") & "#"
    End If
    If Not Me.chkFourn Then
        SQL = SQL & "And tblboncommande!Fournisseur = '" & Me.cmbRechFourn & "' "
    End If
     
    SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
     
    SQL = SQL & ";"
     
    Debug.Print SQL
    Debug.Print SQLWhere
     
    Me.lblStats.Caption = DCount("*", "tblboncommande", SQLWhere) & "/" & DCount("*", "tblboncommande")
    Me.lstResults.RowSource = SQL
    Me.lstResults.Requery
     
    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 RefBon,NumBon,Date,Fournisseur FROM tblboncommande;"
    Me.lstResults.Requery
     
    End Sub

    le Debug.print SQL et le debug.print SQLWhere donnent :

    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 And tblboncommande!NumBon = ;
    tblboncommande!RefBon <> 0 And tblboncommande!NumBon =
    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 And tblboncommande!NumBon = And tblboncommande!Date = ##;
    tblboncommande!RefBon <> 0 And tblboncommande!NumBon = And tblboncommande!Date = ##

  7. #7
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    je recommence (pbm de copier/coller du code).


    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
     
    Private Sub chkDate_Click()
     
    If Me.chkDate Then
        Me.txtRechDate.Visible = False
    Else
        Me.txtRechDate.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub chkFourn_Click()
     
    If Me.chkFourn Then
        Me.cmbRechFourn.Visible = False
    Else
        Me.cmbRechFourn.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub chkNum_Click()
     
    If Me.chknum Then
        Me.txtRechNum.Visible = False
    Else
        Me.txtRechNum.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub cmbRechFourn_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub lstResults_DblClick(Cancel As Integer)
        DoCmd.OpenForm "frmAutoBon", acNormal, , "[RefBon]=" & Me.lstResults
     
    End Sub
     
    Private Sub txtRechDate_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub txtRechNum_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub RefreshQuery()
    Dim SQL As String
    Dim SQLWhere As String
     
    SQL = "SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 "
     
    If Not Me.chknum Then
        SQL = SQL & "And tblboncommande!NumBon = " & Me.txtRechNum
    End If
    If Not Me.chkDate Then
        SQL = SQL & "And tblboncommande!Date = #" & Format(Me.txtRechDate, "mm/dd/yyyy") & "#"
    End If
    If Not Me.chkFourn Then
        SQL = SQL & "And tblboncommande!Fournisseur = '" & Me.cmbRechFourn & "' "
    End If
     
    SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
     
    SQL = SQL & ";"
     
    Debug.Print SQL
    Debug.Print SQLWhere
     
    Me.lblStats.Caption = DCount("*", "tblboncommande", SQLWhere) & "/" & DCount("*", "tblboncommande")
    Me.lstResults.RowSource = SQL
    Me.lstResults.Requery
     
    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 RefBon,NumBon,Date,Fournisseur FROM tblboncommande;"
    Me.lstResults.Requery
     
    End Sub

  8. #8
    Expert éminent
    Avatar de cafeine
    Inscrit en
    Juin 2002
    Messages
    3 904
    Détails du profil
    Informations forums :
    Inscription : Juin 2002
    Messages : 3 904
    Points : 6 781
    Points
    6 781
    Par défaut
    Merci de mettre ton code ENTRE les balises code ...

    Ensuite tu n'as suivi ma recommandation sur les espaces à mettre ...
    Ne mettez pas "Problème" dans vos titres, par définition derrière toute question se cache un problème
    12 tutoriels Access



  9. #9
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    en fait, le formulaire de recherche fonctionne.
    il y a cependant un pbm au début lorsque je clique sur les chkDate et chkNum : il m'indique un message d'erreur :
    erreur de syntaxe (opérateur absent) dans l'expression 'tblboncommande!RefBon <> 0 and tblboncommande!NumBon ='

    là par contre je sèche lamentablement.

  10. #10
    Expert éminent
    Avatar de Lou Pitchoun
    Profil pro
    Inscrit en
    Février 2005
    Messages
    5 038
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Février 2005
    Messages : 5 038
    Points : 8 268
    Points
    8 268
    Par défaut
    Bonjour,

    Merci d'éditer vos messages pour insérer votre code entre balises merci.

  11. #11
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    désolé pour les balises de codes (petites erreur de débutant)

    j'ai changé les espaces comme demandé par caféine.
    le pbm persiste tjrs et le debug.print SQL donne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    SELECT RefBon,NumBon,Date,Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 ;
     
    SELECT RefBon,NumBon,Date,Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0  And tblboncommande!Date = ##;
    là où je bloque c'est que lorsque je clique par exemple sur le chkDate il me met un message d'erreur.
    par contre si je rentre une valeur dans le txtRechDate, ca marche.
    aussi, si je clique sur le chkDate après il ne me met plus le message d'erreur.

  12. #12
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    J'ai une nouvelle fois tout repointer et j'ai toujours le même probleme :
    lorsque je clique sur chkNum et chkDate pour la première fois à l'ouverture du formulaire il me met un message d'erreur.

    le Debug.print donne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande 
    Where tblboncommande!RefBon <> 0  And tblboncommande!NumBon = ;
    SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0  
    And tblboncommande!NumBon =  And tblboncommande!Date = ##;
    LA, JE SECHE LAMENTABLEMENT.

    mon code est 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
    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
     
     
    Private Sub chkDate_Click()
     
    If Me.chkDate Then
        Me.txtRechDate.Visible = False
    Else
        Me.txtRechDate.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub chkFourn_Click()
     
    If Me.chkFourn Then
        Me.cmbRechFourn.Visible = False
    Else
        Me.cmbRechFourn.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub chkNum_Click()
     
    If Me.chknum Then
        Me.txtRechNum.Visible = False
    Else
        Me.txtRechNum.Visible = True
    End If
     
    RefreshQuery
     
    End Sub
     
    Private Sub cmbRechFourn_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub lstResults_DblClick(Cancel As Integer)
        DoCmd.OpenForm "frmAutoBon", acNormal, , "[RefBon]=" & Me.lstResults
     
    End Sub
     
    Private Sub txtRechDate_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub txtRechNum_BeforeUpdate(Cancel As Integer)
     
    RefreshQuery
     
    End Sub
     
    Private Sub RefreshQuery()
    Dim SQL As String
    Dim SQLWhere As String
     
    SQL = "SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 "
     
    If Not Me.chknum Then
        SQL = SQL & " And tblboncommande!NumBon = " & Me.txtRechNum
    End If
    If Not Me.chkDate Then
        SQL = SQL & " And tblboncommande!Date = #" & Format(Me.txtRechDate, "mm/dd/yyyy") & "#"
    End If
    If Not Me.chkFourn Then
        SQL = SQL & " And tblboncommande!Fournisseur = '" & Me.cmbRechFourn & "' "
    End If
     
    SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
     
    SQL = SQL & ";"
     
    Debug.Print SQL
     
    Me.lblStats.Caption = DCount("*", "tblboncommande", SQLWhere) & " / " & DCount("*", "tblboncommande")
    Me.lstResults.RowSource = SQL
    Me.lstResults.Requery
     
    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 RefBon, NumBon, Date, Fournisseur FROM tblboncommande;"
    Me.lstResults.Requery
     
    End Sub
    merci de votre aide.

  13. #13
    Expert éminent
    Avatar de cafeine
    Inscrit en
    Juin 2002
    Messages
    3 904
    Détails du profil
    Informations forums :
    Inscription : Juin 2002
    Messages : 3 904
    Points : 6 781
    Points
    6 781
    Par défaut
    Le debug.print montre que ton code ne récupère pas les valeurs des contrôles ..

    • soit elles sont vides
    • soit le nom du contrôle est mauvais
    • autres ...
    Ne mettez pas "Problème" dans vos titres, par définition derrière toute question se cache un problème
    12 tutoriels Access



  14. #14
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    27
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 27
    Points : 19
    Points
    19
    Par défaut
    CA Y EST CA MARCHE !!!!!

    j'ai mis dans le code ci dessous une valeur (0) à l'ouverture du champ.
    ca ne resoud pas vraiment mon pbm mais ca marche.

    j'ai juste une dernière question : pour le champ Date, si je lui met la valeur 0, il inscrit à l'ouverture la date suivante :30/12/1899.

    que dois je mettre pour qu'il affiche qqch du genre :00/00/0000 ?

    merci d'avance pour votre réponse.

    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
    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 = 0
     
            Case "zdt"
                ctl.Visible = False
                ctl.Value = 0
     
            Case "cmb"
                ctl.Visible = False
     
        End Select
    Next ctl
     
    Me.lstResults.RowSource = "SELECT RefBon, NumBon, DateBon, Fournisseur FROM tblboncommande;"
    Me.lstResults.Requery
     
    End Sub

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

Discussions similaires

  1. Formulaire recherche multicritère
    Par mathgamer18 dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 08/02/2012, 00h39
  2. Réponses: 9
    Dernier message: 21/09/2011, 15h48
  3. [AC-2003] formulaire Recherche multicritère - liste déroulante/Requête
    Par kichnifou dans le forum IHM
    Réponses: 6
    Dernier message: 03/05/2011, 13h27
  4. Formulaire Recherche Multicritère
    Par benjamin002 dans le forum IHM
    Réponses: 2
    Dernier message: 23/11/2009, 17h09
  5. Formulaire Recherche MultiCritère et RunTime
    Par fbu78 dans le forum Runtime
    Réponses: 9
    Dernier message: 06/01/2006, 17h52

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