IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Access Discussion :

Amélioration performance programme VBA sous Access [AC-2007]


Sujet :

VBA Access

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    116
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Juin 2007
    Messages : 116
    Points : 46
    Points
    46
    Par défaut Amélioration performance programme VBA sous Access
    Bonjour à tous,

    quelqu'un pourrait il m'aider à améliorer les performances de ce bout de programme afin qu'il soit beaucoup plus rapide

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
     
     
    Private Sub Cmd_recherche_annee_Click()
     
    'Déclaration des variables
    Dim sql_annee As String
    Dim rs As dao.Recordset
    Dim sql_synth As String
    Dim rs_synth As dao.Recordset
     
    Dim tmp_mois_pose As Integer, tmp_mois_depose As Integer, temp_urgence As Integer
    Dim temp_mois_pose As String, temp_mois_depose As String, temp_bordereau As String, temp_entreprise As String, temp_batiment As String, temp_echafaudage As String
    Dim Nb_jrs As Integer, Annee_depose As Integer, temp_ech_30 As Integer, temp_hpl As Single
    Dim temp_longueur As Single, temp_largeur As Single, temp_hauteur As Single, temp_volume As Single
    Dim ech_1_20 As Single, ech_20 As Single, temp_prevenance As Integer
     
    'On supprime les enregistrements des tables avant de les remettre à jour
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM T_synthese;"
    DoCmd.RunSQL "DELETE * FROM T_synth;"
     
    '***************************************** T_SYNTHESE BEGIN ********************************************************
    sql_annee = "SELECT * FROM T_bordereau LEFT JOIN T_echafaudage ON T_bordereau.Numero_bordereau = T_echafaudage.Numero_bordereau WHERE (((Year([T_echafaudage].[date_pose]))=" & Me.Annee & " ) AND T_bordereau.Avenant = 1);"
    Set rs = CurrentDb.OpenRecordset(sql_annee)
     
    If Not rs.EOF Then
      'on se positionne sur le premier enregistrement
      rs.MoveFirst
      'On boucle sur chaque enregistrement
      While Not rs.EOF
     
        'on récupère le numéro de bordereau
        temp_bordereau = ""
        temp_bordereau = rs("T_bordereau.numero_bordereau")
     
        'on récupère le numéro d'échafaudage
        temp_echafaudage = ""
        temp_echafaudage = rs("numero_echafaudage")
     
        'on récupère et teste le mois de pose
        tmp_mois_pose = 0
        temp_mois_pose = ""
     '   If Not IsNull(rs("T_echafaudage.date_pose")) Then
        If rs("T_echafaudage.date_pose") <> "" Then
        tmp_mois_pose = Month(rs("T_echafaudage.date_pose"))
        If tmp_mois_pose = 1 Then
            temp_mois_pose = "Janvier"
        End If
        If tmp_mois_pose = 2 Then
            temp_mois_pose = "Février"
        End If
        If tmp_mois_pose = 3 Then
            temp_mois_pose = "Mars"
        End If
        If tmp_mois_pose = 4 Then
            temp_mois_pose = "Avril"
        End If
        If tmp_mois_pose = 5 Then
            temp_mois_pose = "Mai"
        End If
        If tmp_mois_pose = 6 Then
            temp_mois_pose = "Juin"
        End If
        If tmp_mois_pose = 7 Then
            temp_mois_pose = "Juillet"
        End If
        If tmp_mois_pose = 8 Then
            temp_mois_pose = "Août"
        End If
        If tmp_mois_pose = 9 Then
            temp_mois_pose = "Septembre"
        End If
        If tmp_mois_pose = 10 Then
            temp_mois_pose = "Octobre"
        End If
        If tmp_mois_pose = 11 Then
            temp_mois_pose = "Novembre"
        End If
        If tmp_mois_pose = 12 Then
            temp_mois_pose = "Décembre"
        End If
        End If
     
        'on récupère et teste le mois de dépose
        tmp_mois_depose = 0
        temp_mois_depose = ""
    '    If Not IsNull(rs("T_echafaudage.date_demande_depose")) Then
        If rs("T_echafaudage.date_demande_depose") <> "" Then
        tmp_mois_depose = Month(rs("T_echafaudage.date_demande_depose"))
        If tmp_mois_depose = 1 Then
            temp_mois_depose = "Janvier"
        End If
        If tmp_mois_depose = 2 Then
            temp_mois_depose = "Février"
        End If
        If tmp_mois_depose = 3 Then
            temp_mois_depose = "Mars"
        End If
        If tmp_mois_depose = 4 Then
            temp_mois_depose = "Avril"
        End If
        If tmp_mois_depose = 5 Then
            temp_mois_depose = "Mai"
        End If
        If tmp_mois_depose = 6 Then
            temp_mois_depose = "Juin"
        End If
        If tmp_mois_depose = 7 Then
            temp_mois_depose = "Juillet"
        End If
        If tmp_mois_depose = 8 Then
            temp_mois_depose = "Août"
        End If
        If tmp_mois_depose = 9 Then
            temp_mois_depose = "Septembre"
        End If
        If tmp_mois_depose = 10 Then
            temp_mois_depose = "Octobre"
        End If
        If tmp_mois_depose = 11 Then
            temp_mois_depose = "Novembre"
        End If
        If tmp_mois_depose = 12 Then
            temp_mois_depose = "Décembre"
        End If
     
        Annee_depose = Year(rs("T_echafaudage.date_demande_depose"))
        'Calcul du nombre de jour entre la date de pose et la date de dépose
        Nb_jrs = 0
        Nb_jrs = DateDiff("d", rs("T_echafaudage.date_pose"), rs("T_echafaudage.date_demande_depose"))
            If Nb_jrs < 0 Then
                Nb_jrs = 0
            End If
        Else
            Nb_jrs = 0
        End If
     
        'Si le nombre de jours entre la date de pose et la date de dépose est supérieur à 30 jours
        temp_ech_30 = 0
        If Nb_jrs > 30 Then
            temp_ech_30 = 1
        Else
            temp_ech_30 = 0
        End If
     
        'on récupère le coef d'urgence
        'Si la case est cochée (valeur = -1)
        temp_urgence = 0
        If rs("coef_K7") = -1 Then
            temp_urgence = 1
        Else
            temp_urgence = 0
        End If
     
        'on récupère la hauteur HPL (hauteur du plancher) --> correspond à la hauteur du garde corps - 1mètre
        temp_hpl = 0
        If rs("hauteur") > 0 Then
        temp_hpl = rs("hauteur") - 1
        If temp_hpl < "1,5" Then
            temp_hpl = 1
        Else
            temp_hpl = 0
        End If
        Else
            temp_hpl = 0
        End If
     
        'on récupère le produit de la Longueur x Largeur x Hauteur (surface)
        temp_hauteur = 0
        temp_largeur = 0
        temp_longueur = 0
        temp_volume = 0
        ech_1_20 = 0
        If (rs("hauteur") > 0 And rs("largeur") > 0 And rs("longueur") > 0) Then
        temp_hauteur = rs("hauteur")
        temp_largeur = rs("largeur")
        temp_longueur = rs("longueur")
        temp_volume = temp_longueur * temp_largeur * temp_hauteur
        If (temp_volume > 1 And temp_volume < 20) Then
            ech_1_20 = 1
        Else
            ech_1_20 = 0
        End If
        If temp_volume > 20 Then
            ech_20 = 1
        Else
            ech_20 = 0
        End If
        End If
     
        temp_entreprise = ""
        temp_batiment = ""
        If rs("nom_entreprise") <> "" Then
            temp_entreprise = rs("nom_entreprise")
        Else
            temp_entreprise = ""
        End If
        If rs("nom_batiment") <> "" Then
            temp_batiment = rs("nom_batiment")
        Else
            temp_batiment = ""
        End If
     
        'on récupère la prévenance
        'Si la case est cochée (valeur = -1)
        temp_prevenance = 0
        If rs("coef_K6") = -1 Then
            temp_prevenance = 1
        Else
            temp_prevenance = 0
        End If
     
        'On insère les données dans la table T_Synthese
        'Si l'entreprise et le batiment sont reneignés
        If (temp_entreprise <> "" And temp_batiment <> "") Then
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synthese (numero_bordereau,numero_echafaudage,mois_pose,mois_depose,urgence,entreprise,batiment,annee_pose,annee_depose,Nb_jrs,ech_30,hpl,ech_1_20,ech_20,prevenance) VALUES('" & temp_bordereau & "', '" & temp_echafaudage & "','" & temp_mois_pose & "', '" & temp_mois_depose & "', " & temp_urgence & ", '" & temp_entreprise & "', '" & temp_batiment & "', " & Me.Annee & "," & Annee_depose & ", " & Nb_jrs & ", " & temp_ech_30 & ", '" & temp_hpl & "', '" & ech_1_20 & "', '" & ech_20 & "', '" & temp_prevenance & "' );"
        End If
     
        'on passe à l'enregistrement suivant
        rs.MoveNext
      Wend
    Else
      MsgBox "Année non trouvée ", vbInformation, "Année"
    End If
     
    rs.Close
    Set rs = Nothing
    '***************************************** T_SYNTHESE END *********************************************************
     
     
     
    '***************************************** T_SYNTH BEGIN ***********************************************************
    sql_synth = "SELECT * FROM T_Synthese ;"
    Set rs_synth = CurrentDb.OpenRecordset(sql_synth)
     
    'Variables mois de pose
    Dim mois_1_p As Integer, mois_2_p As Integer, mois_3_p As Integer, mois_4_p As Integer, mois_5_p As Integer, mois_6_p As Integer, mois_7_p As Integer, mois_8_p As Integer, mois_9_p As Integer, mois_10_p As Integer, mois_11_p As Integer, mois_12_p As Integer
    'Variables mois de dépose
    Dim mois_1_dp As Integer, mois_2_dp As Integer, mois_3_dp As Integer, mois_4_dp As Integer, mois_5_dp As Integer, mois_6_dp As Integer, mois_7_dp As Integer, mois_8_dp As Integer, mois_9_dp As Integer, mois_10_dp As Integer, mois_11_dp As Integer, mois_12_dp As Integer
     
     
    'Variables texte information
    Dim info1 As String, info2 As String, info3 As String, info4 As String, info5 As String, info6 As String, info7 As String, info8 As String, info9 As String, info10 As String, info11 As String
     
    info1 = " Nb Ech Dém"
    info2 = " Nb Ech Mon"
    info3 = " Nb Urgences"
    info4 = "Taux Urgence"
    info5 = "Prévenance >= 4j"
    info6 = "Taux Prévenance"
    info7 = "Nb Echaf avec HPL < 1.5m"
    info8 = "Nb Ech entre 1 et 20m2"
    info9 = "Nb Ech > 20m2"
    info10 = "Nb Ech > 30j"
    info11 = "Durée vie moyenne"
     
    If Not rs_synth.EOF Then
      'on se positionne sur le premier enregistrement
      rs_synth.MoveFirst
      'On boucle sur chaque enregistrement
      While Not rs_synth.EOF
     
    'Cas mois dépose
        mois_1_dp = 0
        If rs_synth("mois_depose") = "Janvier" Then
            mois_1_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_1_dp & " );"
        End If
        mois_2_dp = 0
        If rs_synth("mois_depose") = "Février" Then
            mois_2_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_2_dp & " );"
        End If
        mois_3_dp = 0
        If rs_synth("mois_depose") = "Mars" Then
            mois_3_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_3_dp & " );"
        End If
        mois_4_dp = 0
        If rs_synth("mois_depose") = "Avril" Then
            mois_4_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_4_dp & " );"
        End If
        mois_5_dp = 0
        If rs_synth("mois_depose") = "Mai" Then
            mois_5_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_5_dp & " );"
        End If
        mois_6_dp = 0
        If rs_synth("mois_depose") = "Juin" Then
            mois_6_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_6_dp & " );"
        End If
        mois_7_dp = 0
        If rs_synth("mois_depose") = "Juillet" Then
            mois_7_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_7_dp & " );"
        End If
        mois_8_dp = 0
        If rs_synth("mois_depose") = "Août" Then
            mois_8_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_8_dp & " );"
        End If
        mois_9_dp = 0
        If rs_synth("mois_depose") = "Septembre" Then
            mois_9_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_9_dp & " );"
        End If
        mois_10_dp = 0
        If rs_synth("mois_depose") = "Octobre" Then
            mois_10_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_10_dp & " );"
        End If
        mois_11_dp = 0
        If rs_synth("mois_depose") = "Novembre" Then
            mois_11_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_11_dp & " );"
        End If
        mois_12_dp = 0
        If rs_synth("mois_depose") = "Décembre" Then
            mois_12_dp = 1
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_12_dp & " );"
        End If
        If rs_synth("mois_depose") = "" Then
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "' );"
        End If
     
     
     
    'Cas mois pose
        mois_1_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Janvier" Then
            mois_1_p = 1
     
            'On insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_1_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_2_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Février" Then
            mois_2_p = 1
     
            'On insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_2_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_3_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Mars" Then
            mois_3_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_3_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_4_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Avril" Then
            mois_4_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_4_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_5_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Mai" Then
            mois_5_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_5_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_6_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Juin" Then
            mois_6_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_6_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_7_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Juillet" Then
            mois_7_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_7_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_8_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Août" Then
            mois_8_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_8_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_9_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Septembre" Then
            mois_9_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_9_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_10_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Octobre" Then
            mois_10_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_10_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_11_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Novembre" Then
            mois_11_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_11_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        mois_12_p = 0
        temp_taux_urgence = 0
        temp_taux_prevenance = 0
        If rs_synth("mois_pose") = "Décembre" Then
            mois_12_p = 1
     
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_12_p & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
     
        End If
     
        'on passe à l'enregistrement suivant
        rs_synth.MoveNext
      Wend
     
    End If
     
    rs_synth.Close
    Set rs_synth = Nothing
    '***************************************** T_SYNTH END **********************************************************
     
    End Sub

    D'avance merci
    Blado_sap

  2. #2
    Rédacteur/Modérateur

    Avatar de ClaudeLELOUP
    Homme Profil pro
    Chercheur de loisirs (ayant trouvé tous les jours !)
    Inscrit en
    Novembre 2006
    Messages
    20 596
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 79
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chercheur de loisirs (ayant trouvé tous les jours !)
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 596
    Points : 281 917
    Points
    281 917
    Par défaut
    Bonjour,

    Déjà en remplaçant tes séries de « if then » par des « Select case ». Quand tu sais que c'est 1 pas la peine de demander ensuite si 2, 3, ... 12.

    Si tu postes une db Access2000 avec les tables nécessaires pour tester, j'examinerai plus en détail.

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    116
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Juin 2007
    Messages : 116
    Points : 46
    Points
    46
    Par défaut
    Bonjour,

    merci de ta réponse
    je ne peux malheureusement pas te joindre ma bas car il y a des données confidentielles dedans

    pourrais tu m'aider par rapport au code que j'ai laissé car voit pas trop comment faire avec ce que tu proposes

    D'avance merci
    blado_sap

  4. #4
    Rédacteur/Modérateur

    Avatar de ClaudeLELOUP
    Homme Profil pro
    Chercheur de loisirs (ayant trouvé tous les jours !)
    Inscrit en
    Novembre 2006
    Messages
    20 596
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 79
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chercheur de loisirs (ayant trouvé tous les jours !)
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 596
    Points : 281 917
    Points
    281 917
    Par défaut
    car il y a des données confidentielles dedans
    Tu peux au moins créer un db avec quelques données anonymes


    car voit pas trop comment faire avec ce que tu proposes
    Intéresse-toi à l'instruction Select case.

    Enfonce ta touche F1 et saisi « Select case » dans l'onglet « Aide intuitive »


  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    116
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Juin 2007
    Messages : 116
    Points : 46
    Points
    46
    Par défaut
    voila ce que ca donne
    c'est un peu plus rapide mais c'est mes insert qui ralentissent

    une idée pour améliorer ceci?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
     
     
    Private Sub Cmd_recherche_annee_Click()
     
    'Déclaration des variables
    Dim sql_annee As String
    Dim rs As dao.Recordset
    Dim sql_synth As String
    Dim rs_synth As dao.Recordset
     
    Dim tmp_mois_pose As Integer, tmp_mois_depose As Integer, temp_urgence As Integer
    Dim temp_mois_pose As String, temp_mois_depose As String, temp_bordereau As String, temp_entreprise As String, temp_batiment As String, temp_echafaudage As String
    Dim Nb_jrs As Integer, Annee_depose As Integer, temp_ech_30 As Integer, temp_hpl As Single
    Dim temp_longueur As Single, temp_largeur As Single, temp_hauteur As Single, temp_volume As Single
    Dim ech_1_20 As Single, ech_20 As Single, temp_prevenance As Integer
     
    'On supprime les enregistrements des tables avant de les remettre à jour
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM T_synthese;"
    DoCmd.RunSQL "DELETE * FROM T_synth;"
     
    '***************************************** T_SYNTHESE BEGIN ********************************************************
    sql_annee = "SELECT * FROM T_bordereau LEFT JOIN T_echafaudage ON T_bordereau.Numero_bordereau = T_echafaudage.Numero_bordereau WHERE (((Year([T_echafaudage].[date_pose]))=" & Me.Annee & " ) AND T_bordereau.Avenant = 1);"
    Set rs = CurrentDb.OpenRecordset(sql_annee)
     
    If Not rs.EOF Then
      'on se positionne sur le premier enregistrement
      rs.MoveFirst
      'On boucle sur chaque enregistrement
      While Not rs.EOF
     
        'on récupère le numéro de bordereau
        temp_bordereau = ""
        temp_bordereau = rs("T_bordereau.numero_bordereau")
     
        'on récupère le numéro d'échafaudage
        temp_echafaudage = ""
        temp_echafaudage = rs("numero_echafaudage")
     
        'on récupère et teste le mois de pose
        tmp_mois_pose = 0
        temp_mois_pose = ""
     '   If Not IsNull(rs("T_echafaudage.date_pose")) Then
        If rs("T_echafaudage.date_pose") <> "" Then
            tmp_mois_pose = Month(rs("T_echafaudage.date_pose"))
     
            Select Case tmp_mois_pose
                Case 1
                    temp_mois_pose = "Janvier"
                Case 2
                    temp_mois_pose = "Février"
                Case 3
                    temp_mois_pose = "Mars"
                Case 4
                    temp_mois_pose = "Avril"
                Case 5
                    temp_mois_pose = "Mai"
                Case 6
                    temp_mois_pose = "Juin"
                Case 7
                    temp_mois_pose = "Juillet"
                Case 8
                    temp_mois_pose = "Août"
                Case 9
                    temp_mois_pose = "Septembre"
                Case 10
                    temp_mois_pose = "Octobre"
                Case 11
                    temp_mois_pose = "Novembre"
                Case 12
                    temp_mois_pose = "Décembre"
            End Select
     
        End If
     
        'on récupère et teste le mois de dépose
        tmp_mois_depose = 0
        temp_mois_depose = ""
        Nb_jrs = 0
    '    If Not IsNull(rs("T_echafaudage.date_demande_depose")) Then
        If rs("T_echafaudage.date_demande_depose") <> "" Then
            tmp_mois_depose = Month(rs("T_echafaudage.date_demande_depose"))
     
            Select Case tmp_mois_pose
                Case 1
                    temp_mois_depose = "Janvier"
                Case 2
                    temp_mois_depose = "Février"
                Case 3
                    temp_mois_depose = "Mars"
                Case 4
                    temp_mois_depose = "Avril"
                Case 5
                    temp_mois_depose = "Mai"
                Case 6
                    temp_mois_depose = "Juin"
                Case 7
                    temp_mois_depose = "Juillet"
                Case 8
                    temp_mois_depose = "Août"
                Case 9
                    temp_mois_depose = "Septembre"
                Case 10
                    temp_mois_depose = "Octobre"
                Case 11
                    temp_mois_depose = "Novembre"
                Case 12
                    temp_mois_depose = "Décembre"
            End Select
     
     
        Annee_depose = Year(rs("T_echafaudage.date_demande_depose"))
        'Calcul du nombre de jour entre la date de pose et la date de dépose
     
        Nb_jrs = DateDiff("d", rs("T_echafaudage.date_pose"), rs("T_echafaudage.date_demande_depose"))
            If Nb_jrs < 0 Then
                Nb_jrs = 0
            End If
     
        End If
     
        'Si le nombre de jours entre la date de pose et la date de dépose est supérieur à 30 jours
        temp_ech_30 = 0
        If Nb_jrs > 30 Then
            temp_ech_30 = 1
        End If
     
        'on récupère le coef d'urgence
        'Si la case est cochée (valeur = -1)
        temp_urgence = 0
        If rs("coef_K7") = -1 Then
            temp_urgence = 1
        End If
     
        'on récupère la hauteur HPL (hauteur du plancher) --> correspond à la hauteur du garde corps - 1mètre
        temp_hpl = 0
        If rs("hauteur") > 0 Then
            temp_hpl = rs("hauteur") - 1
            If temp_hpl < "1,5" Then
                temp_hpl = 1
            Else
                temp_hpl = 0
            End If
        End If
     
        'on récupère le produit de la Longueur x Largeur x Hauteur (surface)
        temp_hauteur = 0
        temp_largeur = 0
        temp_longueur = 0
        temp_volume = 0
        ech_1_20 = 0
        ech_20 = 0
        If (rs("hauteur") > 0 And rs("largeur") > 0 And rs("longueur") > 0) Then
            temp_hauteur = rs("hauteur")
            temp_largeur = rs("largeur")
            temp_longueur = rs("longueur")
            temp_volume = temp_longueur * temp_largeur * temp_hauteur
            If (temp_volume > 1 And temp_volume < 20) Then
                ech_1_20 = 1
            End If
            If temp_volume > 20 Then
                ech_20 = 1
            End If
        End If
     
        temp_entreprise = ""
        temp_batiment = ""
        If rs("nom_entreprise") <> "" Then
            temp_entreprise = rs("nom_entreprise")
        End If
        If rs("nom_batiment") <> "" Then
            temp_batiment = rs("nom_batiment")
        End If
     
        'on récupère la prévenance
        'Si la case est cochée (valeur = -1)
        temp_prevenance = 0
        If rs("coef_K6") = -1 Then
            temp_prevenance = 1
        End If
     
        'On insère les données dans la table T_Synthese
        'Si l'entreprise et le batiment sont reneignés
        If (temp_entreprise <> "" And temp_batiment <> "") Then
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synthese (numero_bordereau,numero_echafaudage,mois_pose,mois_depose,urgence,entreprise,batiment,annee_pose,annee_depose,Nb_jrs,ech_30,hpl,ech_1_20,ech_20,prevenance) VALUES('" & temp_bordereau & "', '" & temp_echafaudage & "','" & temp_mois_pose & "', '" & temp_mois_depose & "', " & temp_urgence & ", '" & temp_entreprise & "', '" & temp_batiment & "', " & Me.Annee & "," & Annee_depose & ", " & Nb_jrs & ", " & temp_ech_30 & ", '" & temp_hpl & "', '" & ech_1_20 & "', '" & ech_20 & "', '" & temp_prevenance & "' );"
        End If
     
        'on passe à l'enregistrement suivant
        rs.MoveNext
      Wend
    Else
      MsgBox "Année non trouvée ", vbInformation, "Année"
    End If
     
    rs.Close
    Set rs = Nothing
    '***************************************** T_SYNTHESE END *********************************************************
     
     
     
    '***************************************** T_SYNTH BEGIN ***********************************************************
    sql_synth = "SELECT * FROM T_Synthese ;"
    Set rs_synth = CurrentDb.OpenRecordset(sql_synth)
     
    'Variables mois de pose
    Dim mois_1_p As Integer, mois_2_p As Integer, mois_3_p As Integer, mois_4_p As Integer, mois_5_p As Integer, mois_6_p As Integer, mois_7_p As Integer, mois_8_p As Integer, mois_9_p As Integer, mois_10_p As Integer, mois_11_p As Integer, mois_12_p As Integer
    'Variables mois de dépose
    Dim mois_1_dp As Integer, mois_2_dp As Integer, mois_3_dp As Integer, mois_4_dp As Integer, mois_5_dp As Integer, mois_6_dp As Integer, mois_7_dp As Integer, mois_8_dp As Integer, mois_9_dp As Integer, mois_10_dp As Integer, mois_11_dp As Integer, mois_12_dp As Integer
     
    Dim temp_taux_urgence As Single, temp_taux_prevenance As Single
     
    'Variables texte information
    Dim info1 As String, info2 As String, info3 As String, info4 As String, info5 As String, info6 As String, info7 As String, info8 As String, info9 As String, info10 As String, info11 As String
     
    info1 = " Nb Ech Dém"
    info2 = " Nb Ech Mon"
    info3 = " Nb Urgences"
    info4 = "Taux Urgence"
    info5 = "Prévenance >= 4j"
    info6 = "Taux Prévenance"
    info7 = "Nb Echaf avec HPL < 1.5m"
    info8 = "Nb Ech entre 1 et 20m2"
    info9 = "Nb Ech > 20m2"
    info10 = "Nb Ech > 30j"
    info11 = "Durée vie moyenne"
     
    If Not rs_synth.EOF Then
      'on se positionne sur le premier enregistrement
      rs_synth.MoveFirst
      'On boucle sur chaque enregistrement
      While Not rs_synth.EOF
     
    'Cas mois dépose
      mois_1_dp = 0
      mois_2_dp = 0
      mois_3_dp = 0
      mois_4_dp = 0
      mois_5_dp = 0
      mois_6_dp = 0
      mois_7_dp = 0
      mois_8_dp = 0
      mois_9_dp = 0
      mois_10_dp = 0
      mois_11_dp = 0
      mois_12_dp = 0
     
            Select Case rs_synth("mois_depose")
                Case "Janvier"
                    mois_1_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_1_dp & " );"
                Case "Fevrier"
                    mois_2_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_2_dp & " );"
                Case "Mars"
                    mois_3_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_3_dp & " );"
                Case "Avril"
                    mois_4_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_4_dp & " );"
                Case "Mai"
                    mois_5_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_5_dp & " );"
                Case "Juin"
                    mois_6_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_6_dp & " );"
                Case "Juillet"
                    mois_7_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_7_dp & " );"
                Case "Août"
                    mois_8_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_8_dp & " );"
                Case "Septembre"
                    mois_9_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_9_dp & " );"
                Case "Octobre"
                    mois_10_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_10_dp & " );"
                Case "Novembre"
                    mois_11_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_11_dp & " );"
                Case "Décembre"
                    mois_12_dp = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', " & mois_12_dp & " );"
                Case Else
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "' );"
            End Select
     
    'Cas mois pose
      mois_1_p = 0
      mois_2_p = 0
      mois_3_p = 0
      mois_4_p = 0
      mois_5_p = 0
      mois_6_p = 0
      mois_7_p = 0
      mois_8_p = 0
      mois_9_p = 0
      mois_10_p = 0
      mois_11_p = 0
      mois_12_p = 0
      temp_taux_urgence = 0
      temp_taux_prevenance = 0
     
            Select Case rs_synth("mois_pose")
                Case "Janvier"
                    mois_1_p = 1
                    'On insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_1_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Janvier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Fevrier"
                    mois_2_p = 1
                    'On insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_2_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Fevrier) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Mars"
                    mois_3_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_3_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mars) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Avril"
                    mois_4_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_4_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Avril) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Mai"
                    mois_5_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_5_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Mai) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Juin"
                    mois_6_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_6_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juin) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Juillet"
                    mois_7_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_7_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Juillet) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Août"
                    mois_8_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_8_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Aout) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Septembre"
                    mois_9_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_9_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Septembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Octobre"
                    mois_10_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_10_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Octobre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Novembre"
                    mois_11_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_11_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Novembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
                Case "Décembre"
                    mois_12_p = 1
                    'on insère les données dans la table T_Synth
                    DoCmd.SetWarnings False
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', " & mois_12_p & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
                    DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_Decembre) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
            End Select
     
        'on passe à l'enregistrement suivant
        rs_synth.MoveNext
      Wend
     
    End If
     
    rs_synth.Close
    Set rs_synth = Nothing
    '***************************************** T_SYNTH END **********************************************************
     
    End Sub
    D'avance merci
    Blado_sap

  6. #6
    Expert éminent

    Homme Profil pro
    Inscrit en
    Mai 2012
    Messages
    3 846
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Madagascar

    Informations forums :
    Inscription : Mai 2012
    Messages : 3 846
    Points : 7 983
    Points
    7 983
    Par défaut
    Bonjour,

    Tu as effectivement fait une grosse tartine et je ne comprend pas tes IF avec INSERT à la fin.
    J'ai essayé de factoriser certains trucs. N'ayant pas ta base, j'ai pas pu tester le code joint :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Option Compare Database
    Option Explicit
     
     
    Private Sub Cmd_recherche_annee_Click()
     
    'Déclaration des variables
    Dim sql_annee As String
    Dim rs As DAO.Recordset
    Dim sql_synth As String
    Dim rs_synth As DAO.Recordset
     
    Dim tmp_mois_pose As Integer, tmp_mois_depose As Integer, temp_urgence As Integer
    Dim temp_mois_pose As String, temp_mois_depose As String, temp_bordereau As String, temp_entreprise As String, temp_batiment As String, temp_echafaudage As String
    Dim Nb_jrs As Integer, Annee_depose As Integer, temp_ech_30 As Integer, temp_hpl As Single
    Dim temp_longueur As Single, temp_largeur As Single, temp_hauteur As Single, temp_volume As Single
    Dim ech_1_20 As Single, ech_20 As Single, temp_prevenance As Integer
     
    'On supprime les enregistrements des tables avant de les remettre à jour
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM T_synthese;"
    DoCmd.RunSQL "DELETE * FROM T_synth;"
     
    '***************************************** T_SYNTHESE BEGIN ********************************************************
    sql_annee = "SELECT * FROM T_bordereau LEFT JOIN T_echafaudage ON T_bordereau.Numero_bordereau = T_echafaudage.Numero_bordereau" _
                & " WHERE (((Year([T_echafaudage].[date_pose]))=" & Me.Annee & " ) AND T_bordereau.Avenant = 1);"
    Set rs = CurrentDb.OpenRecordset(sql_annee)
     
    If Not rs.EOF Then
      'on se positionne sur le premier enregistrement
      rs.MoveFirst
      'On boucle sur chaque enregistrement
      While Not rs.EOF
     
        'on récupère le numéro de bordereau
        temp_bordereau = ""
        temp_bordereau = rs("T_bordereau.numero_bordereau")
     
        'on récupère le numéro d'échafaudage
        temp_echafaudage = ""
        temp_echafaudage = rs("numero_echafaudage")
     
        'on récupère et teste le mois de pose
        tmp_mois_pose = 0
        temp_mois_pose = ""
     '   If Not IsNull(rs("T_echafaudage.date_pose")) Then
        If rs("T_echafaudage.date_pose") <> "" Then
            tmp_mois_pose = Month(rs("T_echafaudage.date_pose"))
            temp_mois_pose = fn_temp_mois_pose_depose(tmp_mois_pose)
        End If
     
        'on récupère et teste le mois de dépose
        tmp_mois_depose = 0
        temp_mois_depose = ""
    '    If Not IsNull(rs("T_echafaudage.date_demande_depose")) Then
        If rs("T_echafaudage.date_demande_depose") <> "" Then
           tmp_mois_depose = Month(rs("T_echafaudage.date_demande_depose"))
           temp_mois_depose = fn_temp_mois_pose_depose(tmp_mois_depose)
     
           Annee_depose = Year(rs("T_echafaudage.date_demande_depose"))
           'Calcul du nombre de jour entre la date de pose et la date de dépose
           Nb_jrs = 0
           Nb_jrs = DateDiff("d", rs("T_echafaudage.date_pose"), rs("T_echafaudage.date_demande_depose"))
               If Nb_jrs < 0 Then Nb_jrs = 0
        Else
            Nb_jrs = 0
        End If
     
        'Si le nombre de jours entre la date de pose et la date de dépose est supérieur à 30 jours
        temp_ech_30 = 0
        temp_ech_30 = IIf(Nb_jrs > 30, 1, 0)
     
        'on récupère le coef d'urgence
        'Si la case est cochée (valeur = -1)
        temp_urgence = 0
        temp_urgence = IIf(rs("coef_K7") = -1, 1, 0)
     
        'on récupère la hauteur HPL (hauteur du plancher) --> correspond à la hauteur du garde corps - 1mètre
        temp_hpl = 0
        If rs("hauteur") > 0 Then
            temp_hpl = rs("hauteur") - 1
                If temp_hpl < "1,5" Then
                    temp_hpl = 1
                Else
                    temp_hpl = 0
                End If
        Else
            temp_hpl = 0
        End If
     
        'on récupère le produit de la Longueur x Largeur x Hauteur (surface)
        temp_hauteur = 0
        temp_largeur = 0
        temp_longueur = 0
        temp_volume = 0
        ech_1_20 = 0
        If (rs("hauteur") > 0 And rs("largeur") > 0 And rs("longueur") > 0) Then
            temp_hauteur = rs("hauteur")
            temp_largeur = rs("largeur")
            temp_longueur = rs("longueur")
            temp_volume = temp_longueur * temp_largeur * temp_hauteur
            ech_1_20 = IIf((temp_volume > 1 And temp_volume < 20), 1, 0)
            ech_20 = IIf(temp_volume > 20, 1, 0)
        End If
     
        temp_entreprise = ""
        temp_batiment = ""
        temp_entreprise = IIf(rs("nom_entreprise") <> "", rs("nom_entreprise"), "")
        temp_batiment = IIf(rs("nom_batiment") <> "", rs("nom_batiment"), "")
     
        'on récupère la prévenance
        'Si la case est cochée (valeur = -1)
        temp_prevenance = 0
        temp_prevenance = IIf(rs("coef_K6") = -1, 1, 0)
     
        'On insère les données dans la table T_Synthese
        'Si l'entreprise et le batiment sont reneignés
        If (temp_entreprise <> "" And temp_batiment <> "") Then
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synthese (numero_bordereau,numero_echafaudage,mois_pose,mois_depose,urgence,entreprise,batiment,annee_pose," _
                        & "annee_depose,Nb_jrs,ech_30,hpl,ech_1_20,ech_20,prevenance)" _
                        & " VALUES('" & temp_bordereau & "', '" & temp_echafaudage & "','" & temp_mois_pose & "', '" & temp_mois_depose & "', " & temp_urgence & ", '" & temp_entreprise _
                        & "', '" & temp_batiment & "', " & Me.Annee & "," & Annee_depose & ", " & Nb_jrs & ", " & temp_ech_30 & ", '" & temp_hpl _
                        & "', '" & ech_1_20 & "', '" & ech_20 & "', '" & temp_prevenance & "' );"
        End If
     
        'on passe à l'enregistrement suivant
        rs.MoveNext
      Wend
    Else
      MsgBox "Année non trouvée ", vbInformation, "Année"
    End If
     
    rs.Close
    Set rs = Nothing
    '***************************************** T_SYNTHESE END *********************************************************
     
     
    '***************************************** T_SYNTH BEGIN ***********************************************************
    sql_synth = "SELECT * FROM T_Synthese ;"
    Set rs_synth = CurrentDb.OpenRecordset(sql_synth)
    '???????????????????????????????J'ai pas compris l'utilité des 24 variables suivants à qui tu attribues de toute sles façons à chaqua fois la valeur 1 ????????
    'Variables mois de pose
    Dim mois_1_p As Integer, mois_2_p As Integer, mois_3_p As Integer, mois_4_p As Integer, mois_5_p As Integer, mois_6_p As Integer, mois_7_p As Integer, mois_8_p As Integer, mois_9_p As Integer, mois_10_p As Integer, mois_11_p As Integer, mois_12_p As Integer
    'Variables mois de dépose
    Dim mois_1_dp As Integer, mois_2_dp As Integer, mois_3_dp As Integer, mois_4_dp As Integer, mois_5_dp As Integer, mois_6_dp As Integer, mois_7_dp As Integer, mois_8_dp As Integer, mois_9_dp As Integer, mois_10_dp As Integer, mois_11_dp As Integer, mois_12_dp As Integer
    '????????????????????????????????????????????????????????????????????????????????????????????????????????
     
    'Variables texte information
    Dim info1 As String, info2 As String, info3 As String, info4 As String, info5 As String, info6 As String, info7 As String, info8 As String, info9 As String, info10 As String, info11 As String
     
    info1 = " Nb Ech Dém"
    info2 = " Nb Ech Mon"
    info3 = " Nb Urgences"
    info4 = "Taux Urgence"
    info5 = "Prévenance >= 4j"
    info6 = "Taux Prévenance"
    info7 = "Nb Echaf avec HPL < 1.5m"
    info8 = "Nb Ech entre 1 et 20m2"
    info9 = "Nb Ech > 20m2"
    info10 = "Nb Ech > 30j"
    info11 = "Durée vie moyenne"
     
    If Not rs_synth.EOF Then
      'on se positionne sur le premier enregistrement
      rs_synth.MoveFirst
      'On boucle sur chaque enregistrement
      While Not rs_synth.EOF
     
        'Cas mois dépose
        'Modification : les champs S_Mois (S_Janvier....S_Decembre) peuvent être concaténés avec [S_ & rs_synth("mois_depose")]
        ' et mois_1_dp à mois_12_dp est toujours égal à 1 donc ...
        ' Sauf pour les "" vérifié initialement
        If rs_synth("mois_depose") = "" Then
            'on insère les données dans la table T_Synth
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information) VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "' );"
        Else
            DoCmd.SetWarnings False
            DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_depose") & ")" _
                        & " VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info1 & "', 1);"
            DoCmd.SetWarnings True
        End If
     
     
        'Cas mois pose
        'Modification équivalente à cas mois dépose pour champs S_Mois et
        DoCmd.SetWarnings False
        DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_pose") _
                & ") VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info2 & "', 1);"
        DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_pose") _
                & ") VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info3 & "', " & rs_synth("urgence") & " );"
        DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_pose") _
                & ") VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info5 & "', " & rs_synth("prevenance") & " );"
        DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_pose") _
                & ") VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info7 & "', " & rs_synth("Hpl") & " );"
        DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_pose") _
                & ") VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info8 & "', " & rs_synth("Ech_1_20") & " );"
        DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_pose") _
                & ") VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info9 & "', " & rs_synth("Ech_20") & " );"
        DoCmd.RunSQL "INSERT INTO T_synth (S_Entreprise,S_batiment,S_information,S_" & rs_synth("mois_pose") _
                & ") VALUES('" & rs_synth("entreprise") & "', '" & rs_synth("batiment") & "','" & info10 & "', " & rs_synth("Ech_30") & " );"
        DoCmd.SetWarnings True
        'on passe à l'enregistrement suivant
        rs_synth.MoveNext
      Wend
     
    End If
     
    rs_synth.Close
    Set rs_synth = Nothing
    '***************************************** T_SYNTH END **********************************************************
     
    End Sub
     
    Private Function fn_temp_mois_pose_depose(prposedepose As Integer) As String
    Select Case prposedepose
                Case 1
                    fn_temp_mois_pose_depose = "Janvier"
                Case 2
                    fn_temp_mois_pose_depose = "Février"
                Case 3
                    fn_temp_mois_pose_depose = "Mars"
                Case 4
                    fn_temp_mois_pose_depose = "Avril"
                Case 5
                    fn_temp_mois_pose_depose = "Mai"
                Case 6
                    fn_temp_mois_pose_depose = "Juin"
                Case 7
                    fn_temp_mois_pose_depose = "Juillet"
                Case 8
                    fn_temp_mois_pose_depose = "Août"
                Case 9
                    fn_temp_mois_pose_depose = "Septembre"
                Case 10
                    fn_temp_mois_pose_depose = "Octobre"
                Case 11
                    fn_temp_mois_pose_depose = "Novembre"
                Case 12
                    fn_temp_mois_pose_depose = "Décembre"
            End Select
    End Function
    Cordialement,

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    116
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Juin 2007
    Messages : 116
    Points : 46
    Points
    46
    Par défaut
    Bonjour,

    merci pour cette rectification

    malheureusement le temps d'exécution est toujours aussi long

    Blado_sap

  8. #8
    Expert éminent
    Avatar de jimbolion
    Homme Profil pro
    Moulticien
    Inscrit en
    Janvier 2013
    Messages
    3 150
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Moulticien
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2013
    Messages : 3 150
    Points : 7 001
    Points
    7 001
    Billets dans le blog
    2
    Par défaut
    Blado_sap,

    Ta demande ne fait elle pas double emploi avec celle-ci http://www.developpez.net/forums/d15...n-requete-vba/ sur laquelle je t'apporte une réponse ?

    jimbolion

  9. #9
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    116
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Bas Rhin (Alsace)

    Informations forums :
    Inscription : Juin 2007
    Messages : 116
    Points : 46
    Points
    46
    Par défaut
    Bonjour Jim,

    celle-ci a pour but de remplacer à terme l'autre dont le titre n'est pas du tout parlant afin de faciliter la recherche d'autres utilisateurs qui voudraient s'en inspirer

    et en aucun cas faire doublon

    Blado_sap

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problemes avec grosseur de requete en VBA sous Access
    Par acheo dans le forum Requêtes et SQL.
    Réponses: 3
    Dernier message: 12/04/2007, 11h58
  2. [ETAT]VBA sous access
    Par garfalek dans le forum VBA Access
    Réponses: 5
    Dernier message: 02/04/2007, 20h47
  3. code vba sous access
    Par lifemaker2025 dans le forum Access
    Réponses: 33
    Dernier message: 16/02/2007, 15h17
  4. Accès outlook par programmation VBA depuis access
    Par STOUPI dans le forum Access
    Réponses: 1
    Dernier message: 05/06/2006, 18h22
  5. execute une macro via vba sous access
    Par nes dans le forum Access
    Réponses: 4
    Dernier message: 28/03/2006, 23h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo