formulaire de recherche

Le
alyson
BONJOUR, je veux faire une recherche sur 2 champs, voici
le code que j'ai inscrit, dans ma zone de liste lstResults
rien ne s'affiche, quelqu'un peut m'aider???

merci



Option Compare Database

Private Sub chkFamille_Click()
If Me.chkFamille Then
Me.cmbRechFamille.Visible = False
Else
Me.cmbRechFamille.Visible = True
End If
RefreshQuery
End Sub

Private Sub chkType_Click()

If Me.chkType Then
Me.cmbRechType.Visible = False
Else
Me.cmbRechType.Visible = True
End If
RefreshQuery
End Sub

Private Sub cmbRechFamille_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub

Private Sub cmbRechType_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 NO CONTRLE, CLE PROJET,
DATE, NO PERMIS, FROM CONTROLE;"
Me.lstResults.Requery
End Sub

Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String

SQL = "SELECT NO CONTRLE, CLE PROJET, DATE, NO PERMIS
FROM CONTROLE Where CONTROLE!NO PROJET <> 0 "

If Not Me.chkFamille Then
SQL = SQL & "And CONTROLE!NO CONTRLE = '" &
Me.cmbRechFamille & "' "
End If
If Not Me.chkType Then
SQL = SQL & "And CONTROLE!NO PERMIS = '" &
Me.cmbRechType & "' "
End If

SQLWhere = Trim(Right(SQL, Len(SQL) - InStr
(SQL, "Where ") - Len("Where ") + 1))

SQL = SQL & ";"

Rem Me.lblStats.Caption = DCount("*", "CONTROLE",
SQLWhere) & " / " & DCount("*", "CONTROLE")
Me.lstResults.RowSource = SQL
Me.lstResults.Requery
End Sub


Private Sub lstResults_DblClick(Cancel As Integer)
DoCmd.OpenForm "F-CONTROLE", acNormal, , "[NO CONTRLE]
= " & Me.lstResults
End Sub
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
Rv
Le #4834751
Bonjour,

Comment est défini la liste lstResults (origine source, contenu, colonne
lié, nombre de colonnes)?
A quel moment la recherche est-elle lancée? Double click sur la liste?
Si oui comment le formulaire F-Controle est-il défini (recordsource)?

A+

Rv

"alyson" news:7d7301c402b1$64a5c930$
BONJOUR, je veux faire une recherche sur 2 champs, voici
le code que j'ai inscrit, dans ma zone de liste lstResults
rien ne s'affiche, quelqu'un peut m'aider???

merci



Option Compare Database

Private Sub chkFamille_Click()
If Me.chkFamille Then
Me.cmbRechFamille.Visible = False
Else
Me.cmbRechFamille.Visible = True
End If
RefreshQuery
End Sub

Private Sub chkType_Click()

If Me.chkType Then
Me.cmbRechType.Visible = False
Else
Me.cmbRechType.Visible = True
End If
RefreshQuery
End Sub

Private Sub cmbRechFamille_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub

Private Sub cmbRechType_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 NO CONTRÔLE, CLE PROJET,
DATE, NO PERMIS, FROM CONTROLE;"
Me.lstResults.Requery
End Sub

Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String

SQL = "SELECT NO CONTRÔLE, CLE PROJET, DATE, NO PERMIS
FROM CONTROLE Where CONTROLE!NO PROJET <> 0 "

If Not Me.chkFamille Then
SQL = SQL & "And CONTROLE!NO CONTRÔLE = '" &
Me.cmbRechFamille & "' "
End If
If Not Me.chkType Then
SQL = SQL & "And CONTROLE!NO PERMIS = '" &
Me.cmbRechType & "' "
End If

SQLWhere = Trim(Right(SQL, Len(SQL) - InStr
(SQL, "Where ") - Len("Where ") + 1))

SQL = SQL & ";"

Rem Me.lblStats.Caption = DCount("*", "CONTROLE",
SQLWhere) & " / " & DCount("*", "CONTROLE")
Me.lstResults.RowSource = SQL
Me.lstResults.Requery
End Sub


Private Sub lstResults_DblClick(Cancel As Integer)
DoCmd.OpenForm "F-CONTROLE", acNormal, , "[NO CONTRÔLE]
= " & Me.lstResults
End Sub
Publicité
Poster une réponse
Anonyme