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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
Public Function FctRefreshQuery(ByVal StrRegion As String, ByVal StrDroits As String) As Boolean
Dim SQL As String
Dim SQLWhere As String
Dim BoolPresent As Boolean
Dim db As DAO.Database
Dim rs As DAO.Recordset
On Error GoTo ErrHandler
FctRefreshQuery = False
Form_FrmListeDesIncidents.Requery
BoolPresent = False
'1 - > Entête de la requète
'**************************
SQL = "SELECT Incident.NumIncident, Incident.DatIncident, Incident.CompteRendu, Site.Site, Site.Ville, Ville.Region, Incident.TypIncident" & _
" FROM (((Ville INNER JOIN (Site INNER JOIN Incident ON Site.Site = Incident.NumSite) ON Ville.Ville = Site.Ville) INNER JOIN ReqEstAnalyse ON Incident.NumIncident = ReqEstAnalyse.NumIncident) INNER JOIN ReqEstVisible ON Incident.NumIncident = ReqEstVisible.NumIncident) INNER JOIN ReqEstTraiteNationalement ON Incident.NumIncident = ReqEstTraiteNationalement.NumIncident"
'2 - > Corps de la requète
'*************************
If Not IsNull(Form_FrmListeDesIncidents.CboNumIncident.Value) Then
SQL = SQL & "WHERE Incident.NumIncident = '" & Form_FrmListeDesIncidents.CboNumIncident.Value & "' "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboSite.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Site.Site = '" & Form_FrmListeDesIncidents.CboSite.Value & "' "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboVille.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Site.Ville = '" & Form_FrmListeDesIncidents.CboVille.Value & "' "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboRegion.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Ville.Region = '" & Form_FrmListeDesIncidents.CboRegion.Value & "' "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboTypologie.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Incident.Typologie = '" & Form_FrmListeDesIncidents.CboTypologie.Value & "' "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboTypIncident.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Incident.TypIncident = '" & Form_FrmListeDesIncidents.CboTypIncident.Value & "' "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.TxtDateDebutIncident.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Incident.DatIncident >= #" & Form_FrmListeDesIncidents.TxtDateDebutIncident.Value & "# "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.TxtDateFinIncident.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Incident.DatIncident <= #" & Form_FrmListeDesIncidents.TxtDateFinIncident.Value & "# "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.TxtDateDebutTraitement.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Incident.DateAnalyse <= #" & Form_FrmListeDesIncidents.TxtDateDebutTraitement.Value & "# "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.TxtDateFinTraitement.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Incident.DateAnalyse >= #" & Form_FrmListeDesIncidents.TxtDateFinTraitement.Value & "# "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboStatut.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "Incident.Statut = '" & Form_FrmListeDesIncidents.CboStatut.Value & "' "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboAnalyse.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "((ReqEstAnalyse.EstAnalyse)='" & Form_FrmListeDesIncidents.CboAnalyse.Value & "')"
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboAnalyse.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "((ReqEstVisible.EstVisible)='" & Form_FrmListeDesIncidents.CboMiseEnVisibilité.Value & "') "
BoolPresent = True
End If
If Not IsNull(Form_FrmListeDesIncidents.CboAnalyse.Value) Then
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & "((ReqEstTraiteNationalement.EstTraiteNationalement)='" & Form_FrmListeDesIncidents.CboTraiteNationalement.Value & "'))"
BoolPresent = True
End If
'3 - > Gestion de la visualisation en fonction des droits/région d'origine de la personne
'****************************************************************************************
If StrDroits <> CstAdmin Then
'L'administreateur a une vue globale quelquesoit la région d'origine
If BoolPresent Then
SQL = SQL & " AND "
Else
SQL = SQL & " WHERE "
End If
SQL = SQL & " (((Incident.Statut)='" & "Public" & "')) OR (((Ville.Region)='" & StrRegion & "'))"
End If
BoolPresent = True
SQL = SQL & " ;"
'4 - > Execution de la requète
'*****************************
Form_FrmListeDesIncidents.LstResultQuery.RowSource = SQL
Set rs = CurrentDb.OpenRecordset(SQL, DB_OPEN_DYNASET)
Form_FrmListeDesIncidents.LstResultQuery.RowSourceType = "Table/Query"
'5 - > Remplissage du ListView
'*****************************
Set Form_FrmListeDesIncidents.LstResultQuery.Recordset = rs
ExitHandler:
Set rs = Nothing
Exit Function
ErrHandler:
MsgBox Err.Description, vbExclamation, CstAppName
FctRefreshQuery = False
Resume ExitHandler
End Function |
Partager