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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| Option Compare Database
Private Sub chknom_Click()
If Me.chknom Then
Me.txtrechnom.Visible = False
Else
Me.txtrechnom.Visible = True
End If
RefreshQuery
End Sub
Private Sub chkprenom_Click()
If Me.chkprenom Then
Me.txtrechprenom.Visible = False
Else
Me.txtrechprenom.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 Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case Left(ctl.Name, 3)
Case "chk"
ctl.Value = -1
Case "txt"
ctl.Visible = False
ctl.Value = ""
Case "cmb"
ctl.Visible = False
End Select
Next ctl
Me.listresults1.RowSource = "SELECT Utilisateurs.Nom, Utilisateurs.Prenom, Utilisateurs.NumSegula, Utilisateurs.[Mot de passe] FROM Utilisateurs;"
Me.listresults1.Requery
End Sub
Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
SQL = "SELECT Nom, Prenom, NumSegula FROM Utilisateurs Where Utilisateurs!Nom is not null "
If Not Me.chknom Then
SQL = SQL & "And Utilisateurs!Nom like '*" & Me.txtrechnom & "*' "
End If
If Not Me.chkprenom Then
SQL = SQL & "And Utilisateurs!Prenom like '*" & Me.txtrechprenom & "*' "
End If
If Not Me.chknum Then
SQL = SQL & "And Utilisateurs!NumSegula like '*" & Me.txtrechnum & "*' "
End If
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
SQL = SQL & ";"
Me.listresults1.RowSource = SQL
Me.listresults1.Requery
End Sub
Private Sub listResults1_DblClick(Cancel As Integer)
'Controle d'erreur
On Error GoTo Err_listResults1_DblClick
DoCmd.OpenForm "AutoUtilisateurs", acNormal, , "[Nom] = " & Me.listresults1
Exit_listResults1_DblClick:
Exit Sub 'Ou Exit Function
'Liste des différentes erreurs se produisant
Err_listResults1_DblClick:
Select Case Err.Number
Case 2501
'OK, erreur 'normale', ne rien faire
Case 3075
Case Else
MsgBox "L'erreur " & Err.Number & ", " & err_description & " s'est produite. Merci de faire une copie d'écran et de prévenir le support technique.", vbExclamation
End Select
End Sub
Private Sub txtrechnom_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub txtrechprenom_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub txtrechnum_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub Quitter_Click()
On Error GoTo Err_Quitter_Click
DoCmd.Quit
Exit_Quitter_Click:
Exit Sub
Err_Quitter_Click:
MsgBox Err.Description
Resume Exit_Quitter_Click
End Sub |
Partager