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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
| Function Creerfiltre() As String
'Déclaration des variables
Dim f As String, strVal As String, lgAge1 As Long, lgAge2 As Long, dtHeure1 As Date, dtHeure2 As Date
Dim strListeCJou As String
Dim dtPeriode1 As Date, dtPeriode2 As Date
f = ""
' SELECTION DE LA DATE PRECISE
strVal = Nz(Me.Rdate, "")
If strVal <> "" And IsDate(strVal) Then
If f <> "" Then f = f & " AND "
f = f & "[Date]=#" & Format(CDate(strVal), "mm\/dd\/yyyy") & "#"
End If
' SELECTION DU JOUR DE LA SEMAINE
strVal = Nz(Me.Rjour_sem.Column(1), "") ' colonne 2
If strVal <> "" Then
If f <> "" Then f = f & " AND "
f = f & "Jsem = """ & strVal & """"
End If
' SELECTION DU MOIS
strVal = Nz(Me.Rmois.Column(1), "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Month([Date])=" & strVal
End If
' SELETION DE L'ANNEE
strVal = Nz(Me.RAnnee, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Year([Date])=" & strVal
End If
' SELECTION DE L'HEURE (tranche horaire)
dtHeure1 = Nz(Me.Rtranche_horaire1, #1/1/1900#)
dtHeure2 = Nz(Me.Rtranche_horaire2, #1/1/1900#)
If (dtHeure1 <> #1/1/1900#) And (dtHeure2 <> #1/1/1900#) Then
If f <> "" Then f = f & " AND "
If dtHeure1 <= dtHeure2 Then
f = f & "[Heure2] BETWEEN #" & Format(dtHeure1, "hh:nn") & "# AND #" & Format(dtHeure2, "hh:nn") & "#"
Else
f = f & "([Heure2] BETWEEN #" & Format(dtHeure1, "hh:nn:ss") & "# AND #23:59:59#"
f = f & " OR "
f = f & "[Heure2] BETWEEN #00:00:00# AND #" & Format(dtHeure2, "hh:nn:ss") & "#)"
End If
End If
' SELECTION DE LA PERIODE
dtPeriode1 = Nz(Me.Rperiode1, #1/1/1900#)
dtPeriode2 = Nz(Me.Rperiode2, #1/1/1900#)
If (dtPeriode1 <> #1/1/1900#) And (dtPeriode2 <> #1/1/1900#) Then
If f <> "" Then f = f & " AND "
f = f & "[Date] BETWEEN #" & Format(dtPeriode1, "mm\/dd\/yyyy") & "# AND #" & Format(dtPeriode2, "mm\/dd\/yyyy") & "#"
End If
' Si toutes les options sont sélectionnées : pas de critère sur champ CJou
' (Pas de critère = tout)
' Sinon ...
If Not (Me.OptWE And Me.OptSemaine And Me.OptVFete And Me.OptFete) Then
' SELECTION DU WEEK-END
If Me.OptWE = True Then
If strListeCJou <> "" Then strListeCJou = strListeCJou & ", "
strListeCJou = strListeCJou & "'Sam', 'Dim'"
End If
' SELECTION DE LA SEMAINE
If Me.OptSemaine = True Then
If strListeCJou <> "" Then strListeCJou = strListeCJou & ", "
strListeCJou = strListeCJou & "'Sem'"
End If
' SELECTION DE LA VEILLE DE FETE
If Me.OptVFete = True Then
If strListeCJou <> "" Then strListeCJou = strListeCJou & ", "
strListeCJou = strListeCJou & "'VFet'"
End If
' SELECTION DE LA FETE
If Me.OptFete = True Then
If strListeCJou <> "" Then strListeCJou = strListeCJou & ", "
strListeCJou = strListeCJou & "'Fet'"
End If
' Ajout du critère sur champ CJou
If Len(strListeCJou) > 0 Then
If f <> "" Then f = f & " AND "
f = f & "CJou IN (" & strListeCJou & ")"
End If
End If
' SELECTION DE LA LUMINOSITE
strVal = Nz(Me.RLuminosite, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Lumi = """ & strVal & """"
End If
' SELECTION DES CONDITIONS ATMOSPHERIQUES
strVal = Nz(Me.RAtmo, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Atmo = """ & strVal & """"
End If
' SELECTION DU PROFIL EN LONG
strVal = Nz(Me.RProfil, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Plong = """ & strVal & """"
End If
' SELECTION DU TRACE EN PLAN
strVal = Nz(Me.RTrace, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "[TPlan] = """ & strVal & """"
End If
' SELECTION DE L'ETAT DE SURFACE
strVal = Nz(Me.REtat, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "[Surf] = """ & strVal & """"
End If
' SELECTION DE L'AMENAGEMENT DE L'INFRASTRUCTURE
strVal = Nz(Me.RAmenagement, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "[Amen] = """ & strVal & """"
End If
' SELECTION DE LA COMMUNE
strVal = Nz(Me.RCom, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "[Com] = """ & strVal & """"
End If
' SELECTION D'UNE INTERSECTION
' LIKE permet de ne pas écrire exactement l'adresse
'strVal = Nz(Me.RInter, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "Intersection LIKE ""*" & strVal & "*"""
'End If
' SELECTION DU TYPE D'INTERSECTION
strVal = Nz(Me.Rtype_inter, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Inter = """ & strVal & """"
End If
' SELECTION DE L'ADRESSE
' LIKE permet de ne pas écrire exactement l'adresse
strVal = Nz(Me.Radresse, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Adresse_concatenee_1 LIKE ""*" & strVal & "*"""
End If
' SELECTION DE LA CATEGORIE DE VOIE
strVal = Nz(Me.RCat_voie, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "CatR = """ & strVal & """"
End If
' SELECTION DU NUMERO (adresse)
' SELECTION DE LA VOIE SPECIALE
strVal = Nz(Me.RVoie_spec, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "VoiSp = """ & strVal & """"
End If
' SELECTION DE LA LOCALISATION DE L'ACCIDENT
strVal = Nz(Me.RLoca, "")
If strVal <> "" And strVal <> "- - Choisir - -" Then
If f <> "" Then f = f & " AND "
f = f & "Situa = """ & strVal & """"
End If
' SELECTION DE LA PROXIMITE OU NON D'UNE ECOLE
' SELECTION DU VEHICULE A IMPLIQUE
'strVal = Nz(Me.RvehiculeA, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "CAdmin = """ & strVal & """"
'End If
' SELECTION DU VEHICULE B IMPLIQUE
'strVal = Nz(Me.RvehiculeB, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "Cadmin_2 = """ & strVal & """"
'End If
' SELECTION DU TYPE DE COLLISION
'strVal = Nz(Me.Rtypecol, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "Tcol = """ & strVal & """"
'End If
' SELECTION DE L AGE (tranche d'âge)
'lgAge1 = Nz(Me.Txtage1, 0)
'lgAge2 = Nz(Me.Txtage2, 0)
'If lgAge1 <> 0 And lgAge2 <> 0 Then
' If f <> "" Then f = f & " AND "
' f = f & "AgU BETWEEN " & CStr(lgAge1) & " AND " & CStr(lgAge2)
'End If
' SELECTION DU SEXE
'strVal = Nz(Me.Rsexe, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "Sexe = """ & strVal & """"
'End If
' SELECTION DE LA CATEGORIE DE L'USAGER
'strVal = Nz(Me.Rcat_usager, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "CatU = """ & strVal & """"
'End If
' SELECTION DU NOMBRE DE VEHICULES IMPLIQUES
'strVal = Nz(Me.Rnbvehic, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "Nveh = " & strVal
'End If
' SELECTION DU NOMBRE D'USAGERS IMPLIQUES
'strVal = Nz(Me.Rnbusagers, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "Nusa = " & strVal
'End If
' NOMBRE DE TUES
'strVal = Nz(Me.RNbtues, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "Ntu = " & strVal
'End If
' NOMBRE DE BLESSES HOSPITALISES
'strVal = Nz(Me.RNbBH, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "NBH = " & strVal
'End If
' NOMBRE DE BLESSES NON HOSPITALISES
'strVal = Nz(Me.RNbBNH, "")
'If strVal <> "" And strVal <> "- - Choisir - -" Then
' If f <> "" Then f = f & " AND "
' f = f & "NBNH = " & strVal
'End If
Creerfiltre = f
' Me.txtFiltre = f
End Function |
Partager