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
| Option Compare Database
Private Sub Cocher11_Click()
Me.Txt_fin.Visible = Not Me.Txt_fin.Visible
RefreshQuery
End Sub
Private Sub Cocher13_Click()
Me.txt_debut.Visible = Not Me.txt_debut.Visible
RefreshQuery
End Sub
Private Sub Cocher15_Click()
Me.Liste_prenom.Visible = Not Me.Liste_prenom.Visible
RefreshQuery
End Sub
Private Sub Cocher9_Click()
Me.liste_nom.Visible = Not Me.liste_nom.Visible
RefreshQuery
End Sub
Private Sub liste_nom_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub Liste_prenom_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
SQL = "SELECT ID_stages, Nom, Prenom, Date_debut, Date_fin FROM Stages Where Stages!ID_Stage > 0 "
If Nz(Me.Cocher9, False) Then
SQL = SQL & "And Stages!Nom = '" & Me.liste_nom & "' "
End If
If Nz(Me.Cocher15, False) Then
SQL = SQL & "And Stages!Prenom = '" & Me.Liste_prenom & "' "
End If
If Nz(Me.Cocher13, False) Then
SQL = SQL & "And Stages!Date_debut => '" & Me.txt_debut & "' "
End If
If Nz(Me.Cocher11, False) Then
SQL = SQL & "And Stages!Date_fin =< '" & Me.Txt_fin & "' "
End If
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
SQL = SQL & ";"
Debug.Print SQL
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 "Lis"
ctl.Value = -1
Case "Coc"
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 ID_stages, Nom, Prenom, Date_debut, Date_fin FROM Stages;"
Me.lstResults.Requery
End Sub
Private Sub lstResults_DblClick(Cancel As Integer)
DoCmd.OpenForm "frm_Autostages", acNormal, , "[ID_stage] = " & Me.lstResults
End Sub
Private Sub Txt_debut_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub Txt_fin_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub |
Partager