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 276 277 278 279
| Private Sub btn_Trier_Click()
Dim str_Provenance As String
Dim str_Destination1 As String
Dim str_Destination2 As String
Dim str_Destination3 As String
Dim str_NumeroMouvement As String
Dim str_Alliage As String
Dim str_NumeroOf As String
Dim str_NumeroLingot As String
Dim str_DateDebut As String
Dim str_DateFin As String
'Dim str_Filtre As String
Dim str_DateDebutSlash As String
Dim str_DateFinSlash As String
Dim str_Description As String
Dim str_MasseMinimum As String
Dim str_MasseMinimum1 As String
Dim str_MasseMinimum2 As String
Dim str_MasseMinimum3 As String
Dim str_MasseMaximum As String
Dim str_MasseMaximum1 As String
Dim str_MasseMaximum2 As String
Dim str_MasseMaximum3 As String
Dim lng_MasseMaxSaisie As Long
Dim lng_MasseMinSaisie As Long
Dim str_PieceMinimum As String
Dim str_PieceMinimum1 As String
Dim str_PieceMinimum2 As String
Dim str_PieceMinimum3 As String
Dim str_PieceMaximum As String
Dim str_PieceMaximum1 As String
Dim str_PieceMaximum2 As String
Dim str_PieceMaximum3 As String
Dim lng_PieceMaxSaisie As Long
Dim lng_PieceMinSaisie As Long
' ### DATES ###
If (Me![ch_inde_date_debut] <> "") And (Me![ch_inde_date_fin] <> "") Then
str_DateDebutSlash = "#" & Left(Me![ch_inde_date_debut], 2) & "/" & Mid(Me![ch_inde_date_debut], 4, 2) & "/" & Right(Me![ch_inde_date_debut], 4) & "#"
str_DateFinSlash = "#" & Left(Me![ch_inde_date_fin], 2) & "/" & Mid(Me![ch_inde_date_fin], 4, 2) & "/" & Right(Me![ch_inde_date_fin], 4) & "#"
str_DateDebut = "(FRM_gesor_inventaire.date_creation_inventaire >" & str_DateDebutSlash & ")"
str_DateFin = "(FRM_gesor_inventaire.date_creation_inventaire <" & str_DateFinSlash & ")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_DateDebut & "AND" & str_DateFin
Else
str_Filtre = str_Filtre & "AND" & "(" & str_DateDebut & "AND" & str_DateFin & ")"
End If
End If
' ### PROVENANCE ###
If Me![ch_inde_provenance] <> "" Then
str_Provenance = "(FRM_gesor_inventaire.provenance_inventaire Like ""*" & Me![ch_inde_provenance] & "*"")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_Provenance
Else
str_Filtre = str_Filtre & "AND" & str_Provenance
End If
End If
' ### DESTINATION ###
If Me![ch_inde_destination] <> "" Then
str_Destination1 = "(FRM_gesor_inventaire.destination1_inventaire Like ""*" & Me![ch_inde_destination] & "*"")"
str_Destination2 = "(FRM_gesor_inventaire.destination2_inventaire Like ""*" & Me![ch_inde_destination] & "*"")"
str_Destination3 = "(FRM_gesor_inventaire.destination3_inventaire Like ""*" & Me![ch_inde_destination] & "*"")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_Destination1 & "Or" & str_Destination2 & "Or" & str_Destination3
Else
str_Filtre = str_Filtre & "AND" & str_Destination1 & "Or" & str_Destination2 & "Or" & str_Destination3
End If
End If
' ### NUMERO DE MOUVEMENT ###
If Me![ch_inde_numero_mouvement] <> "" Then
str_NumeroMouvement = "(FRM_gesor_inventaire.numero_mouvement_inventaire Like ""*" & Me![ch_inde_numero_mouvement] & "*"")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_NumeroMouvement
Else
str_Filtre = str_Filtre & "AND" & str_NumeroMouvement
End If
End If
' ### ALLIAGE ###
If Me![ch_inde_alliage] <> "" Then
str_Alliage = "(FRM_gesor_inventaire.alliage_inventaire Like ""*" & Me![ch_inde_alliage] & "*"")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_Alliage
Else
str_Filtre = str_Filtre & "AND" & str_Alliage
End If
End If
' ### NUMERO D'OF ###
If Me![ch_inde_of] <> "" Then
str_NumeroOf = "(FRM_gesor_inventaire.numero_of_inventaire Like ""*" & Me![ch_inde_of] & "*"")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_NumeroOf
Else
str_Filtre = str_Filtre & "AND" & str_NumeroOf
End If
End If
' ### NUMERO DE LINGOT ###
If Me![ch_inde_lingot] <> "" Then
str_NumeroLingot = "(FRM_gesor_inventaire.numero_lingot_inventaire Like ""*" & Me![ch_inde_lingot] & "*"")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_NumeroLingot
Else
str_Filtre = str_Filtre & "AND" & str_NumeroLingot
End If
End If
' ### Description###
If Me![ch_inde_description] <> "" Then
str_Description = "(FRM_gesor_inventaire.description_inventaire Like ""*" & Me![ch_inde_description] & "*"")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & str_Description
Else
str_Filtre = str_Filtre & "AND" & str_Description
End If
End If
' ### MASSES ###
If (Me![ch_inde_masse_min] <> "") And (Me![ch_inde_masse_max] <> "") Then
lng_MasseMaxSaisie = Me![ch_inde_masse_max]
lng_MasseMinSaisie = Me![ch_inde_masse_min]
str_MasseMinimum1 = "(FRM_gesor_inventaire.masse1_inventaire >" & lng_MasseMinSaisie & ")"
str_MasseMinimum2 = "(FRM_gesor_inventaire.masse2_inventaire >" & lng_MasseMinSaisie & ")"
str_MasseMinimum3 = "(FRM_gesor_inventaire.masse3_inventaire >" & lng_MasseMinSaisie & ")"
str_MasseMaximum1 = "(FRM_gesor_inventaire.masse1_inventaire <" & lng_MasseMaxSaisie & ")"
str_MasseMaximum2 = "(FRM_gesor_inventaire.masse2_inventaire <" & lng_MasseMaxSaisie & ")"
str_MasseMaximum3 = "(FRM_gesor_inventaire.masse3_inventaire <" & lng_MasseMaxSaisie & ")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & "(" & (str_MasseMinimum1) & "Or" & (str_MasseMinimum2) & "Or" & (str_MasseMinimum3) & ")" & "AND" & _
"(" & (str_MasseMaximum1) & "Or" & (str_MasseMaximum2) & "Or" & (str_MasseMaximum3) & ")"
Else
str_Filtre = str_Filtre & "AND" & "(" & (str_MasseMinimum1) & "Or" & (str_MasseMinimum2) & "Or" & (str_MasseMinimum3) & ")" & "AND" & _
"(" & (str_MasseMaximum1) & "Or" & (str_MasseMaximum2) & "Or" & (str_MasseMaximum3) & ")"
End If
End If
' ### PIECES ###
If (Me![ch_inde_piece_min] <> "") And (Me![ch_inde_piece_max] <> "") Then
lng_PieceMaxSaisie = Me![ch_inde_piece_max]
lng_PieceMinSaisie = Me![ch_inde_piece_min]
str_PieceMinimum1 = "(FRM_gesor_inventaire.nb_piece1_inventaire >" & lng_PieceMinSaisie & ")"
str_PieceMinimum2 = "(FRM_gesor_inventaire.nb_piece2_inventaire >" & lng_PieceMinSaisie & ")"
str_PieceMinimum3 = "(FRM_gesor_inventaire.nb_piece3_inventaire >" & lng_PieceMinSaisie & ")"
str_PieceMaximum1 = "(FRM_gesor_inventaire.nb_piece1_inventaire <" & lng_PieceMaxSaisie & ")"
str_PieceMaximum2 = "(FRM_gesor_inventaire.nb_piece2_inventaire <" & lng_PieceMaxSaisie & ")"
str_PieceMaximum3 = "(FRM_gesor_inventaire.nb_piece3_inventaire <" & lng_PieceMaxSaisie & ")"
If str_Filtre = "" Then
str_Filtre = str_Filtre & "(" & (str_PieceMinimum1) & "Or" & (str_PieceMinimum2) & "Or" & (str_PieceMinimum3) & ")" & "AND" & _
"(" & (str_PieceMaximum1) & "Or" & (str_PieceMaximum2) & "Or" & (str_PieceMaximum3) & ")"
Else
str_Filtre = str_Filtre & "AND" & "(" & (str_PieceMinimum1) & "Or" & (str_PieceMinimum2) & "Or" & (str_PieceMinimum3) & ")" & "AND" & _
"(" & (str_PieceMaximum1) & "Or" & (str_PieceMaximum2) & "Or" & (str_PieceMaximum3) & ")"
End If
End If
'Application des filtres
Me.Filter = str_Filtre
Me.FilterOn = True
End Sub |
Partager