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
| Option Compare Database
Private Sub chkLigne_click()
'Permet d'activer la comboBox "Ligne" si la checkBox "Ligne" est cochée
Me.cmbLigne.Visible = chkLigne
RefreshQuery
End Sub
Private Sub chkMachine_click()
'Permet d'activer la comboBox "Machine" si la checkBox "Machine" est cochée
Me.cmbMachine.Visible = chkMachine.Value
RefreshQuery
End Sub
Private Sub chkCategorie_click()
'Permet d'activer la comboBox "Categorie" si la checkBox "Categorie" est cochée
Me.cmbCategorie.Visible = chkCategorie
RefreshQuery
End Sub
Private Sub cmbCategorie_BeforeUpdate(Cancel As Integer)
'Recherche dynamique dans la comboBox cmbCategorie
RefreshQuery
End Sub
Private Sub cmbLigne_BeforeUpdate(Cancel As Integer)
'Recherche dynamique dans la comboBox cmbLigne
RefreshQuery
End Sub
Private Sub cmbMachine_BeforeUpdate(Cancel As Integer)
'Recherche dynamique dans la comboBox cmbMachine
RefreshQuery
End Sub
Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
SQL = "SELECT id_Art, IDDesignation, Référence, Ligne, Machine FROM tbl_Article Where tbl_Article!id_Art <> 0 "
If Me.chkLigne And Not IsNull(Me.cmbLigne) Then
SQL = SQL & "And tbl_Article!Ligne = " & Me.cmbLigne & " "
End If
If Me.chkMachine And Not IsNull(Me.cmbMachine) Then
SQL = SQL & "And tbl_Article!Machine = " & Me.cmbMachine & " "
End If
If Me.chkCategorie And Not IsNull(Me.cmbCategorie) Then
SQL = SQL & "And tbl_Article!Categorie = " & Me.cmbCategorie & " "
End If
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
SQL = SQL & ";"
Me.lblStats.Caption = DCount("*", "tbl_Article", SQLWhere) & " / " & DCount("*", "tbl_Article")
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 = False
Case "lbl"
ctl.Caption = "- * - * -"
Case "cmb"
ctl.Visible = False
End Select
Next ctl
'Me.lstResults.RowSource = "SELECT id_Art, IDDesignation, Référence, Ligne, Machine FROM tbl_Article;"
'Me.lstResults.Requery
RefreshQuery
End Sub |
Partager