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
| Dim IP As String
Dim IP2 As String
Dim IC As String
Dim D1 As String
Dim D2 As String
Dim D11 As String
Dim D22 As String
Dim I1 As String
Dim n As String
Dim nn As String
Dim p As Integer
Dim AV As Double
Dim NV As Double
Dim myrst As DAO.Recordset
Dim ty As Integer
Set Db = CurrentDb
p = Me.lmd_P
ty = Me.lmd_F.Column(3)
DoCmd.SetWarnings (False)
'-----------------------------Identifiant projet---------------------------------------
sSQL = "SELECT Projet.ID_P FROM Projet GROUP BY Projet.ID_P, Projet.Selection HAVING (((Projet.ID_P)<> " & p & ") AND ((Projet.Selection)=True));"
IP = "(Rqt_Détail_Projet.ID_P)=" & p & ""
IP2 = "(Rqt_Détail_Certu_MOA.ID_P)=" & p & ""
Set myrst = Db.OpenRecordset(sSQL)
If Not myrst.EOF Then
' tant qu'il n'est pas vide
Do While Not myrst.EOF
IP = IP & " Or (Rqt_Détail_Projet.ID_P)= " & myrst.Fields("ID_P").Value & ""
IP2 = IP2 & " Or (Rqt_Détail_Certu_MOA.ID_P)= " & myrst.Fields("ID_P").Value & ""
myrst.MoveNext
Loop
End If
myrst.Close
Set myrst = Nothing
'-----------------------------Identifiant projet par type---------------------------------------
sSQL = "SELECT Projet.ID_P, Famille.ID_Type"
sSQL = sSQL & " FROM Famille INNER JOIN Projet ON Famille.ID_F = Projet.ID_F"
sSQL = sSQL & " WHERE (((Projet.ID_P)<>" & p & ") AND ((Famille.ID_Type)=" & ty & "));"
IPT = "(Rqt_Détail_Certu_MOA.ID_P)=" & p & ""
Set myrst = Db.OpenRecordset(sSQL)
If Not myrst.EOF Then
' tant qu'il n'est pas vide
Do While Not myrst.EOF
IPT = IPT & " Or (Rqt_Détail_Certu_MOA.ID_P)= " & myrst.Fields("ID_P").Value & ""
myrst.MoveNext
Loop
End If
myrst.Close
Set myrst = Nothing
'------------------------------Identifiant Poste Certu------------------------------------------
sSQL = "SELECT Liste_Poste_Certu.Num_Certu FROM Liste_Poste_Certu GROUP BY Liste_Poste_Certu.Num_Certu, Liste_Poste_Certu.Selection HAVING (((Liste_Poste_Certu.Selection)=True));"
i = 0
Set myrst = Db.OpenRecordset(sSQL)
If Not myrst.EOF Then
' tant qu'il n'est pas vide
Do While Not myrst.EOF
i = i + 1
If i = 1 Then
IC = "(Rqt_Data_Par_PCertu.Num_Certu)= " & myrst.Fields("Num_Certu").Value & ""
Else
IC = IC & " Or (Rqt_Data_Par_PCertu.Num_Certu)= " & myrst.Fields("Num_Certu").Value & ""
End If
myrst.MoveNext
Loop
End If
myrst.Close
Set myrst = Nothing
'-------------------------------------------------suite programme------------------------------------
sSQL = "Delete * FROM Tbl_MAJ_CE"
DoCmd.RunSQL (sSQL)
sSQL = "SELECT Rqt_Détail_Projet.ID_P, Rqt_Détail_Projet.Montant_Projet,Rqt_Détail_Projet.CE_Projet, Rqt_Détail_Certu_MOA.ID_DP,Rqt_Détail_Certu_MOA.ID_DP2,Rqt_Détail_Certu_MOA.ID_PMOA,Rqt_Détail_Certu_MOA.ID_SPMOA,Rqt_Détail_Certu_MOA.ID_DMOA,Rqt_Détail_Certu_MOA.ID_SP_Certu,Rqt_Détail_Certu_MOA.ID_Desig,Rqt_Détail_Certu_MOA.ID_R, Rqt_Détail_Certu_MOA.Nom_Ouvrage,Rqt_Détail_Certu_MOA.Num_Certu,Rqt_Détail_Certu_MOA.Montant_PCertu, Rqt_Détail_Certu_MOA.PU_PCertu, Rqt_Détail_Certu_MOA.Indice_PCertu, Rqt_Détail_Certu_MOA.CE_PCertu"
sSQL = sSQL & " FROM Rqt_Détail_Projet INNER JOIN Rqt_Détail_Certu_MOA ON Rqt_Détail_Projet.ID_P = Rqt_Détail_Certu_MOA.ID_P"
sSQL = sSQL & " WHERE ((" & IP & "));"
Set myrst = Db.OpenRecordset(sSQL)
'si le recordset n'est pas vide
If Not myrst.EOF Then
' tant qu'il n'est pas vide
Do While Not myrst.EOF
D1 = myrst.Fields("CE_PCertu").Value
I1 = myrst.Fields("Indice_PCertu").Value
PUC = myrst.Fields("PU_PCertu").Value
MP = myrst.Fields("Montant_Projet").Value
MPC = myrst.Fields("Montant_PCertu").Value
ID = myrst.Fields("ID_DP").Value
ID2 = myrst.Fields("ID_DP2").Value
D2 = Me.Lmd_D.Column(1)
D3 = myrst.Fields("CE_Projet").Value
'----------------Montant et PU-----------------------------------------
If Len(D1) > 0 And Len(D2) > 0 Then
a = Split("" & D1 & "", "/")
If a(0) <= 12 Then
D11 = a(1) & "/" & a(0) & "/" & a(2)
End If
b = Split("" & D2 & "", "/")
If b(0) <= 12 Then
D22 = b(1) & "/" & b(0) & "/" & b(2)
End If
C = Split("" & D3 & "", "/")
If C(0) <= 12 Then
D33 = C(1) & "/" & C(0) & "/" & C(2)
End If
AV = DLookup("" & I1 & "", "Liste_Indice", "[Date_Indice]= #" & D11 & "#")
AVP = DLookup("" & I1 & "", "Liste_Indice", "[Date_Indice]= #" & D33 & "#")
NV = DLookup("" & I1 & "", "Liste_Indice", "[Date_Indice]= #" & D22 & "#")
tmp = Round(((MP * NV) / AVP), 0)
tmp = Replace(tmp, ",", ".")
tmpc = Round(((MPC * NV) / AV), 0)
tmpc = Replace(tmpc, ",", ".")
tc = Round((PUC * NV) / AV, 2)
tc = Replace(tc, ",", ".")
Else
tc = PUC
tmp = MP
tmpc = MPC
End If
'---------------------------------Suite programme----------------------------------------------------
nn = "x"
vv = "x"
For Each f In myrst.Fields
n = f.Name & 2
v = myrst.Fields("[" & f.Name & "]").Value
If nn = "x" Then
nn = "[" & n & "]"
Else
nn = nn & ", " & "[" & n & "]"
End If
If vv = "x" Then
vv = "'" & v & "'"
Else
vv = vv & ", " & "'" & v & "'"
End If
Next
sSQL = "INSERT INTO [Tbl_MAJ_CE] (" & nn & ") VALUES (" & vv & ")"
DoCmd.RunSQL (sSQL)
sSQL = "UPDATE [Tbl_MAJ_CE] SET PU_PCertu2= " & tc & ",Montant_Projet2=" & tmp & ",Montant_PCertu2=" & tmpc & ", CE_PCertu2= #" & D22 & "#, CE_Projet2= #" & D22 & "# WHERE [ID_DP2]=" & ID & ""
DoCmd.RunSQL (sSQL)
myrst.MoveNext
Loop
End If
myrst.Close
Set myrst = Nothing
DoCmd.SetWarnings (True)
sSQL = "SELECT Rqt_Détail_Certu_MOA.ID_P, Rqt_Data_Par_PCertu.Montant_Projet AS MP, Rqt_Data_Par_PCertu.Montant_Projet2 AS MPA, Rqt_Data_Par_PCertu.CE_Projet AS CEP, Rqt_Data_Par_PCertu.CE_Actu AS CE_PA, Rqt_Data_Par_PCertu.Num_Certu AS NC, Rqt_Data_Par_PCertu.Nom_Certu, Rqt_Data_Par_PCertu.MPC, Rqt_Data_Par_PCertu.MPCA, Rqt_Data_Par_PCertu.MPCSSAV, Rqt_Data_Par_PCertu.MPCASSAV, Rqt_Data_Par_PCertu.CE AS CE_PC, Rqt_Data_Par_SPCertu.Nom_SP_Certu, Rqt_Data_Par_SPCertu.MSPC, Rqt_Data_Par_SPCertu.MSPCA, Rqt_Data_Par_SPCertu.MSPCSSAV, Rqt_Data_Par_SPCertu.MSPCASSAV, Rqt_Data_Par_SPCertu.CE AS CE_SPC, Rqt_Data_Par_Desig.Nom_Desig, Rqt_Data_Par_Desig.MD, Rqt_Data_Par_Desig.MDA, Rqt_Data_Par_Desig.MDSSAV, Rqt_Data_Par_Desig.MDASSAV, Rqt_Data_Par_Desig.CE AS CE_D, Rqt_Data_Par_Ressources.Nom_R, Rqt_Data_Par_Ressources.MR, Rqt_Data_Par_Ressources.MRA, Rqt_Data_Par_Ressources.MRSSAV, Rqt_Data_Par_Ressources.MRASSAV, Rqt_Data_Par_Ressources.CE AS CE_R, Rqt_Data_Par_PCertu.Longueur,"
sSQL = sSQL & " Rqt_Data_Par_PCertu.Longueur_Travailler , Rqt_Data_Par_PCertu.GLO , Rqt_Data_Par_PCertu.Nb_Stations_simple, Rqt_Data_Par_PCertu.Nb_Stations_double, Rqt_Data_Par_PCertu.Capacite_SMR, Rqt_Data_Par_PCertu.Montant_BT, Rqt_Data_Par_PCertu.Montant_BT_Actu, Rqt_Data_Par_PCertu.Montant_BT_Sans_SAV, Rqt_Data_Par_PCertu.Montant_BT_Actu_Sans_SAV, Rqt_Détail_Certu_MOA.Nom_PMOA, Rqt_Détail_Certu_MOA.Nom_SPMOA, Rqt_Détail_Certu_MOA.Nom_DMOA"
sSQL = sSQL & " FROM (((Rqt_Détail_Certu_MOA LEFT JOIN Rqt_Data_Par_PCertu ON (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_PCertu.ID_P) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_PCertu.Num_Certu)) LEFT JOIN Rqt_Data_Par_SPCertu ON (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_SPCertu.ID_P) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_SPCertu.Num_Certu) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_SPCertu.Nom_SP_Certu)) LEFT JOIN Rqt_Data_Par_Desig ON (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Desig.ID_P) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Desig.Num_Certu) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Desig.Nom_SP_Certu) AND (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Desig.Nom_Desig)) LEFT JOIN Rqt_Data_Par_Ressources ON (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Ressources.ID_P) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Ressources.Num_Certu) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Ressources.Nom_SP_Certu) AND"
sSQL = sSQL & " (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Ressources.Nom_Desig) AND (Rqt_Détail_Certu_MOA.Nom_R = Rqt_Data_Par_Ressources.Nom_R)"
sSQL = sSQL & " WHERE (((Rqt_Détail_Certu_MOA.ID_P)=" & p & "));"
DoCmd.DeleteObject acQuery, "Rqt_Data_Regroupe_0"
CurrentDb.CreateQueryDef "Rqt_Data_Regroupe_0", sSQL
sSQL = "SELECT Rqt_Détail_Certu_MOA.ID_P, Rqt_Data_Par_PCertu_NO.Montant_Projet AS MP, Rqt_Data_Par_PCertu_NO.Montant_Projet2 AS MPA, Rqt_Data_Par_PCertu_NO.CE_Projet AS CEP, Rqt_Data_Par_PCertu_NO.CE_Actu AS CE_PA, Rqt_Data_Par_PCertu_NO.Num_Certu AS NC, Rqt_Data_Par_PCertu_NO.Nom_Certu, Rqt_Data_Par_PCertu_NO.Nom_Ouvrage, Rqt_Data_Par_PCertu_NO.MPC, Rqt_Data_Par_PCertu_NO.MPCA, Rqt_Data_Par_PCertu_NO.MPCSSAV, Rqt_Data_Par_PCertu_NO.MPCASSAV, Rqt_Data_Par_PCertu_NO.CE AS CE_PC, Rqt_Data_Par_SPCertu_NO.Nom_SP_Certu, Rqt_Data_Par_SPCertu_NO.MSPC, Rqt_Data_Par_SPCertu_NO.MSPCA, Rqt_Data_Par_SPCertu_NO.MSPCSSAV, Rqt_Data_Par_SPCertu_NO.MSPCASSAV, Rqt_Data_Par_SPCertu_NO.CE AS CE_SPC, Rqt_Data_Par_Desig_NO.Nom_Desig, Rqt_Data_Par_Desig_NO.MD, Rqt_Data_Par_Desig_NO.MDA, Rqt_Data_Par_Desig_NO.MDSSAV, Rqt_Data_Par_Desig_NO.MDASSAV, Rqt_Data_Par_Desig_NO.CE AS CE_D, Rqt_Data_Par_Ressources_NO.Nom_R, Rqt_Data_Par_Ressources_NO.MR, Rqt_Data_Par_Ressources_NO.MRA, Rqt_Data_Par_Ressources_NO.MRSSAV,"
sSQL = sSQL & " Rqt_Data_Par_Ressources_NO.MRASSAV, Rqt_Data_Par_Ressources_NO.CE AS CE_R, Rqt_Data_Par_PCertu_NO.Longueur, Rqt_Data_Par_PCertu_NO.Longueur_Travailler, Rqt_Data_Par_PCertu_NO.GLO, Rqt_Data_Par_PCertu_NO.Nb_Stations_simple, Rqt_Data_Par_PCertu_NO.Nb_Stations_double, Rqt_Data_Par_PCertu_NO.Capacite_SMR, Rqt_Data_Par_PCertu_NO.Montant_BT, Rqt_Data_Par_PCertu_NO.Montant_BT_Actu, Rqt_Data_Par_PCertu_NO.Montant_BT_Sans_SAV, Rqt_Data_Par_PCertu_NO.Montant_BT_Actu_Sans_SAV, Rqt_Détail_Certu_MOA.Nom_PMOA, Rqt_Détail_Certu_MOA.Nom_SPMOA, Rqt_Détail_Certu_MOA.Nom_DMOA"
sSQL = sSQL & " FROM (((Rqt_Détail_Certu_MOA LEFT JOIN Rqt_Data_Par_PCertu_NO ON (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_PCertu_NO.ID_P) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_PCertu_NO.Num_Certu) AND (Rqt_Détail_Certu_MOA.Nom_Ouvrage = Rqt_Data_Par_PCertu_NO.Nom_Ouvrage)) LEFT JOIN Rqt_Data_Par_SPCertu_NO ON (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_SPCertu_NO.ID_P) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_SPCertu_NO.Num_Certu) AND (Rqt_Détail_Certu_MOA.Nom_Ouvrage = Rqt_Data_Par_SPCertu_NO.Nom_Ouvrage) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_SPCertu_NO.Nom_SP_Certu)) LEFT JOIN Rqt_Data_Par_Desig_NO ON (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Desig_NO.ID_P) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Desig_NO.Num_Certu) AND (Rqt_Détail_Certu_MOA.Nom_Ouvrage = Rqt_Data_Par_Desig_NO.Nom_Ouvrage) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Desig_NO.Nom_SP_Certu) AND (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Desig_NO.Nom_Desig)) LEFT JOIN"
sSQL = sSQL & " Rqt_Data_Par_Ressources_NO On (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Ressources_NO.ID_P) And (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Ressources_NO.Num_Certu) And (Rqt_Détail_Certu_MOA.Nom_Ouvrage = Rqt_Data_Par_Ressources_NO.Nom_Ouvrage) And (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Ressources_NO.Nom_SP_Certu) And (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Ressources_NO.Nom_Desig) And (Rqt_Détail_Certu_MOA.Nom_R = Rqt_Data_Par_Ressources_NO.Nom_R)"
sSQL = sSQL & " WHERE (((Rqt_Détail_Certu_MOA.ID_P)=" & p & "));"
DoCmd.DeleteObject acQuery, "Rqt_Data_Regroupe_NO_0"
CurrentDb.CreateQueryDef "Rqt_Data_Regroupe_NO_0", sSQL
sSQL = "SELECT Rqt_Détail_Projet.ID_Infra, Rqt_Détail_Projet.Nom_Infra, Rqt_Détail_Projet.ID_F, Rqt_Détail_Projet.Nom_F, Rqt_Détail_Projet.Nom_Type, Rqt_Détail_Projet.ID_P, Rqt_Détail_Projet.Nom_P, Rqt_Détail_Projet.Montant_Projet, Tbl_MAJ_CE.Montant_Projet2 AS Montant_Projet_Actu, Rqt_Détail_Projet.Longueur, Rqt_Détail_Projet.Longueur_Travailler, Rqt_Détail_Projet.GLO, Rqt_Détail_Projet.Nb_Stations_simple, Rqt_Détail_Projet.Nb_Stations_double, Rqt_Détail_Projet.Capacite_SMR, Rqt_Détail_Projet.ID_MOE, Rqt_Détail_Projet.Nom_MOE, Rqt_Détail_Projet.ID_MOA, Rqt_Détail_Projet.Nom_MOA, Rqt_Détail_Projet.ID_Source, Rqt_Détail_Projet.Nom_Source, Rqt_Détail_Projet.Type_Source, Rqt_Détail_Projet.Lieu_Source, Rqt_Détail_Projet.Producteur, Rqt_Détail_Projet.Etape, Rqt_Détail_Projet.CE_Projet, Tbl_MAJ_CE.CE_Projet2 AS CE_Projet_Actu"
sSQL = sSQL & " FROM Rqt_Détail_Projet INNER JOIN Tbl_MAJ_CE ON Rqt_Détail_Projet.ID_P = Tbl_MAJ_CE.ID_P2"
sSQL = sSQL & " GROUP BY Rqt_Détail_Projet.ID_Infra, Rqt_Détail_Projet.Nom_Infra, Rqt_Détail_Projet.ID_F, Rqt_Détail_Projet.Nom_F, Rqt_Détail_Projet.Nom_Type, Rqt_Détail_Projet.ID_P, Rqt_Détail_Projet.Nom_P, Rqt_Détail_Projet.Montant_Projet, Tbl_MAJ_CE.Montant_Projet2, Rqt_Détail_Projet.Longueur, Rqt_Détail_Projet.Longueur_Travailler, Rqt_Détail_Projet.GLO, Rqt_Détail_Projet.Nb_Stations_simple, Rqt_Détail_Projet.Nb_Stations_double, Rqt_Détail_Projet.Capacite_SMR, Rqt_Détail_Projet.ID_MOE, Rqt_Détail_Projet.Nom_MOE, Rqt_Détail_Projet.ID_MOA, Rqt_Détail_Projet.Nom_MOA, Rqt_Détail_Projet.ID_Source, Rqt_Détail_Projet.Nom_Source, Rqt_Détail_Projet.Type_Source, Rqt_Détail_Projet.Lieu_Source, Rqt_Détail_Projet.Producteur, Rqt_Détail_Projet.Etape, Rqt_Détail_Projet.CE_Projet, Tbl_MAJ_CE.CE_Projet2"
sSQL = sSQL & " HAVING (((Rqt_Détail_Projet.ID_P)=" & p & "));"
DoCmd.DeleteObject acQuery, "Rqt_Fiche_Projet_Caractéristique"
CurrentDb.CreateQueryDef "Rqt_Fiche_Projet_Caractéristique", sSQL
sSQL = "SELECT Rqt_Data_fiche_projet.ID_P, Rqt_Data_fiche_projet.Num_Certu, Rqt_Data_fiche_projet.Nom_Certu, Rqt_Data_fiche_projet.Nom_SP_Certu, Rqt_Data_fiche_projet.Nom_Desig, Rqt_Data_fiche_projet.Nom_R, Rqt_Data_fiche_projet.Nom_Ouvrage, Rqt_Data_fiche_projet.Nom_PMOA, Rqt_Data_fiche_projet.Nom_SPMOA, Rqt_Data_fiche_projet.Nom_DMOA, Rqt_Data_fiche_projet.Montant_PCertu AS MPMOA, Rqt_Data_fiche_projet.Montant_PCertu2 AS MPMOAA, Round(([Montant_PCertu]/(1+[SAV_PCertu])),0) AS MPMOASSAV, Round(([Montant_PCertu2]/(1+[SAV_PCertu])),0) AS MPMOAASSAV, Rqt_Data_fiche_projet.PU_PCertu AS PUMOA, Rqt_Data_fiche_projet.PU_PCertu2 AS PUAMOA, Rqt_Data_fiche_projet.Unite_PCertu, Rqt_Data_fiche_projet.CE_PCertu AS CE, Rqt_Data_fiche_projet.CE_PCertu2 AS CE_Actu, Rqt_Data_fiche_projet.Montant_Projet"
sSQL = sSQL & " FROM Rqt_Data_fiche_projet INNER JOIN Rqt_Base_Travaux ON Rqt_Data_fiche_projet.ID_P = Rqt_Base_Travaux.ID_P"
sSQL = sSQL & " GROUP BY Rqt_Data_fiche_projet.ID_P, Rqt_Data_fiche_projet.Num_Certu, Rqt_Data_fiche_projet.Nom_Certu, Rqt_Data_fiche_projet.Nom_SP_Certu, Rqt_Data_fiche_projet.Nom_Desig, Rqt_Data_fiche_projet.Nom_R, Rqt_Data_fiche_projet.Nom_Ouvrage, Rqt_Data_fiche_projet.Nom_PMOA, Rqt_Data_fiche_projet.Nom_SPMOA, Rqt_Data_fiche_projet.Nom_DMOA, Rqt_Data_fiche_projet.Montant_PCertu, Rqt_Data_fiche_projet.Montant_PCertu2, Round(([Montant_PCertu]/(1+[SAV_PCertu])),0), Round(([Montant_PCertu2]/(1+[SAV_PCertu])),0), Rqt_Data_fiche_projet.PU_PCertu, Rqt_Data_fiche_projet.PU_PCertu2, Rqt_Data_fiche_projet.Unite_PCertu, Rqt_Data_fiche_projet.CE_PCertu, Rqt_Data_fiche_projet.CE_PCertu2, Rqt_Data_fiche_projet.Montant_Projet"
sSQL = sSQL & " HAVING (((Rqt_Data_fiche_projet.ID_P)=" & p & "));"
DoCmd.DeleteObject acQuery, "Rqt_Data_Par_PMOA"
CurrentDb.CreateQueryDef "Rqt_Data_Par_PMOA", sSQL
sSQL = "SELECT Rqt_Détail_Certu_MOA.ID_P, Rqt_Data_Par_PCertu.Nom_P, Rqt_Data_Par_PCertu.Montant_Projet AS MP, Rqt_Data_Par_PCertu.Montant_Projet2 AS MPA, Rqt_Data_Par_PCertu.CE_Projet AS CEP, Rqt_Data_Par_PCertu.CE_Actu AS CE_PA,Rqt_Data_Par_PCertu.Etape, Rqt_Data_Par_PCertu.Num_Certu AS NC, Rqt_Data_Par_PCertu.Nom_Certu, Rqt_Data_Par_PCertu.MPC, Rqt_Data_Par_PCertu.MPCA, Rqt_Data_Par_PCertu.MPCSSAV, Rqt_Data_Par_PCertu.MPCASSAV, Rqt_Data_Par_PCertu.CE AS CE_PC, Rqt_Data_Par_SPCertu.Nom_SP_Certu, Rqt_Data_Par_SPCertu.MSPC,"
sSQL = sSQL & " Rqt_Data_Par_SPCertu.MSPCA, Rqt_Data_Par_SPCertu.MSPCSSAV, Rqt_Data_Par_SPCertu.MSPCASSAV, Rqt_Data_Par_SPCertu.CE AS CE_SPC, Rqt_Data_Par_Desig.Nom_Desig, Rqt_Data_Par_Desig.MD, Rqt_Data_Par_Desig.MDA, Rqt_Data_Par_Desig.MDSSAV, Rqt_Data_Par_Desig.MDASSAV, Rqt_Data_Par_Desig.CE AS CE_D, Rqt_Data_Par_Ressources.Nom_R, Rqt_Data_Par_Ressources.MR, Rqt_Data_Par_Ressources.MRA, Rqt_Data_Par_Ressources.MRSSAV, Rqt_Data_Par_Ressources.MRASSAV, Rqt_Data_Par_Ressources.CE AS CE_R, Rqt_Data_Par_PCertu.Longueur,"
sSQL = sSQL & " Rqt_Data_Par_PCertu.Longueur_Travailler , Rqt_Data_Par_PCertu.GLO, Rqt_Data_Par_PCertu.Nb_Stations_simple, Rqt_Data_Par_PCertu.Nb_Stations_double, Rqt_Data_Par_PCertu.Capacite_SMR, Rqt_Data_Par_PCertu.Montant_BT, Rqt_Data_Par_PCertu.Montant_BT_Actu, Rqt_Data_Par_PCertu.Montant_BT_Sans_SAV, Rqt_Data_Par_PCertu.Montant_BT_Actu_Sans_SAV"
sSQL = sSQL & " FROM (((Rqt_Détail_Certu_MOA LEFT JOIN Rqt_Data_Par_PCertu ON (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_PCertu.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_PCertu.ID_P)) LEFT JOIN Rqt_Data_Par_SPCertu ON (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_SPCertu.Nom_SP_Certu) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_SPCertu.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_SPCertu.ID_P)) LEFT JOIN Rqt_Data_Par_Desig ON (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Desig.Nom_Desig) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Desig.Nom_SP_Certu) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Desig.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Desig.ID_P)) LEFT JOIN Rqt_Data_Par_Ressources ON (Rqt_Détail_Certu_MOA.Nom_R = Rqt_Data_Par_Ressources.Nom_R) AND (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Ressources.Nom_Desig) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Ressources.Nom_SP_Certu) AND"
sSQL = sSQL & " (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Ressources.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Ressources.ID_P)"
sSQL = sSQL & " GROUP BY Rqt_Détail_Certu_MOA.ID_P, Rqt_Data_Par_PCertu.Nom_P, Rqt_Data_Par_PCertu.Montant_Projet, Rqt_Data_Par_PCertu.Montant_Projet2, Rqt_Data_Par_PCertu.CE_Projet, Rqt_Data_Par_PCertu.CE_Actu,Rqt_Data_Par_PCertu.Etape, Rqt_Data_Par_PCertu.Num_Certu , Rqt_Data_Par_PCertu.Nom_Certu, Rqt_Data_Par_PCertu.MPC, Rqt_Data_Par_PCertu.MPCA, Rqt_Data_Par_PCertu.MPCSSAV, Rqt_Data_Par_PCertu.MPCASSAV, "
sSQL = sSQL & " Rqt_Data_Par_PCertu.ce , Rqt_Data_Par_SPCertu.Nom_SP_Certu, Rqt_Data_Par_SPCertu.MSPC, Rqt_Data_Par_SPCertu.MSPCA, Rqt_Data_Par_SPCertu.MSPCSSAV, Rqt_Data_Par_SPCertu.MSPCASSAV, Rqt_Data_Par_SPCertu.ce, Rqt_Data_Par_Desig.Nom_Desig, Rqt_Data_Par_Desig.MD, Rqt_Data_Par_Desig.MDA, Rqt_Data_Par_Desig.MDSSAV, Rqt_Data_Par_Desig.MDASSAV, Rqt_Data_Par_Desig.ce, Rqt_Data_Par_Ressources.Nom_R, Rqt_Data_Par_Ressources.MR, Rqt_Data_Par_Ressources.MRA, Rqt_Data_Par_Ressources.MRSSAV, Rqt_Data_Par_Ressources.MRASSAV, Rqt_Data_Par_Ressources.ce, Rqt_Data_Par_PCertu.Longueur, Rqt_Data_Par_PCertu.Longueur_Travailler, Rqt_Data_Par_PCertu.GLO, "
sSQL = sSQL & " Rqt_Data_Par_PCertu.nb_Stations_simple , Rqt_Data_Par_PCertu.Nb_Stations_double, Rqt_Data_Par_PCertu.Capacite_SMR, Rqt_Data_Par_PCertu.Montant_BT, Rqt_Data_Par_PCertu.Montant_BT_Actu, Rqt_Data_Par_PCertu.Montant_BT_Sans_SAV, Rqt_Data_Par_PCertu.Montant_BT_Actu_Sans_SAV"
sSQL = sSQL & " HAVING ((" & IP2 & ") AND (" & IC & "));"
DoCmd.DeleteObject acQuery, "Rqt_Data_Regroupe_0_bis"
CurrentDb.CreateQueryDef "Rqt_Data_Regroupe_0_bis", sSQL
sSQL = "SELECT Rqt_Détail_Certu_MOA.ID_P, Rqt_Data_Par_PCertu.Nom_P, Rqt_Data_Par_PCertu.Montant_Projet AS MP, Rqt_Data_Par_PCertu.Montant_Projet2 AS MPA, Rqt_Data_Par_PCertu.CE_Projet AS CEP, Rqt_Data_Par_PCertu.CE_Actu AS CE_PA, Rqt_Data_Par_PCertu.Num_Certu AS NC, Rqt_Data_Par_PCertu.Nom_Certu, Rqt_Data_Par_PCertu.MPC, Rqt_Data_Par_PCertu.MPCA, Rqt_Data_Par_PCertu.MPCSSAV, Rqt_Data_Par_PCertu.MPCASSAV, Rqt_Data_Par_PCertu.CE AS CE_PC, Rqt_Data_Par_SPCertu.Nom_SP_Certu, Rqt_Data_Par_SPCertu.MSPC, Rqt_Data_Par_SPCertu.MSPCA, Rqt_Data_Par_SPCertu.MSPCSSAV, Rqt_Data_Par_SPCertu.MSPCASSAV, Rqt_Data_Par_SPCertu.CE AS CE_SPC, Rqt_Data_Par_Desig.Nom_Desig, Rqt_Data_Par_Desig.MD, Rqt_Data_Par_Desig.MDA, Rqt_Data_Par_Desig.MDSSAV, Rqt_Data_Par_Desig.MDASSAV, Rqt_Data_Par_Desig.CE AS CE_D, Rqt_Data_Par_Ressources.Nom_R, Rqt_Data_Par_Ressources.MR, Rqt_Data_Par_Ressources.MRA, Rqt_Data_Par_Ressources.MRSSAV, Rqt_Data_Par_Ressources.MRASSAV, Rqt_Data_Par_Ressources.CE AS CE_R, Rqt_Data_Par_PCertu.Longueur,"
sSQL = sSQL & " Rqt_Data_Par_PCertu.Longueur_Travailler , Rqt_Data_Par_PCertu.GLO, Rqt_Data_Par_PCertu.Nb_Stations_simple, Rqt_Data_Par_PCertu.Nb_Stations_double, Rqt_Data_Par_PCertu.Capacite_SMR, Rqt_Data_Par_PCertu.Montant_BT, Rqt_Data_Par_PCertu.Montant_BT_Actu, Rqt_Data_Par_PCertu.Montant_BT_Sans_SAV, Rqt_Data_Par_PCertu.Montant_BT_Actu_Sans_SAV"
sSQL = sSQL & " FROM (((Rqt_Détail_Certu_MOA LEFT JOIN Rqt_Data_Par_PCertu ON (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_PCertu.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_PCertu.ID_P)) LEFT JOIN Rqt_Data_Par_SPCertu ON (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_SPCertu.Nom_SP_Certu) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_SPCertu.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_SPCertu.ID_P)) LEFT JOIN Rqt_Data_Par_Desig ON (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Desig.Nom_Desig) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Desig.Nom_SP_Certu) AND (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Desig.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Desig.ID_P)) LEFT JOIN Rqt_Data_Par_Ressources ON (Rqt_Détail_Certu_MOA.Nom_R = Rqt_Data_Par_Ressources.Nom_R) AND (Rqt_Détail_Certu_MOA.Nom_Desig = Rqt_Data_Par_Ressources.Nom_Desig) AND (Rqt_Détail_Certu_MOA.Nom_SP_Certu = Rqt_Data_Par_Ressources.Nom_SP_Certu) AND"
sSQL = sSQL & " (Rqt_Détail_Certu_MOA.Num_Certu = Rqt_Data_Par_Ressources.Num_Certu) AND (Rqt_Détail_Certu_MOA.ID_P = Rqt_Data_Par_Ressources.ID_P)"
sSQL = sSQL & " GROUP BY Rqt_Détail_Certu_MOA.ID_P, Rqt_Data_Par_PCertu.Nom_P, Rqt_Data_Par_PCertu.Montant_Projet, Rqt_Data_Par_PCertu.Montant_Projet2, Rqt_Data_Par_PCertu.CE_Projet, Rqt_Data_Par_PCertu.CE_Actu, Rqt_Data_Par_PCertu.Num_Certu, Rqt_Data_Par_PCertu.Nom_Certu, Rqt_Data_Par_PCertu.MPC, Rqt_Data_Par_PCertu.MPCA, Rqt_Data_Par_PCertu.MPCSSAV, Rqt_Data_Par_PCertu.MPCASSAV, Rqt_Data_Par_PCertu.CE, Rqt_Data_Par_SPCertu.Nom_SP_Certu, Rqt_Data_Par_SPCertu.MSPC, Rqt_Data_Par_SPCertu.MSPCA, Rqt_Data_Par_SPCertu.MSPCSSAV, Rqt_Data_Par_SPCertu.MSPCASSAV, Rqt_Data_Par_SPCertu.CE, Rqt_Data_Par_Desig.Nom_Desig, Rqt_Data_Par_Desig.MD, Rqt_Data_Par_Desig.MDA, Rqt_Data_Par_Desig.MDSSAV, Rqt_Data_Par_Desig.MDASSAV, Rqt_Data_Par_Desig.CE, Rqt_Data_Par_Ressources.Nom_R, Rqt_Data_Par_Ressources.MR, Rqt_Data_Par_Ressources.MRA, Rqt_Data_Par_Ressources.MRSSAV, Rqt_Data_Par_Ressources.MRASSAV, Rqt_Data_Par_Ressources.CE, Rqt_Data_Par_PCertu.Longueur, Rqt_Data_Par_PCertu.Longueur_Travailler, Rqt_Data_Par_PCertu.GLO,"
sSQL = sSQL & " Rqt_Data_Par_PCertu.nb_Stations_simple , Rqt_Data_Par_PCertu.Nb_Stations_double, Rqt_Data_Par_PCertu.Capacite_SMR, Rqt_Data_Par_PCertu.Montant_BT, Rqt_Data_Par_PCertu.Montant_BT_Actu, Rqt_Data_Par_PCertu.Montant_BT_Sans_SAV, Rqt_Data_Par_PCertu.Montant_BT_Actu_Sans_SAV"
sSQL = sSQL & " HAVING ((" & IPT & ") AND (" & IC & "));"
DoCmd.DeleteObject acQuery, "Rqt_Data_Regroupe_0_type"
CurrentDb.CreateQueryDef "Rqt_Data_Regroupe_0_type", sSQL
Set xlapp = CreateObject("Excel.Application")
xlapp.Visible = True
xlapp.Workbooks.Open ("C:\Documents and Settings\stif\Mes documents\coût\base de données\Fiche Projet.xlsm")
xlapp.Workbooks("Fiche Projet.xlsm").sheets("Data").Activate
xlapp.Close
Set xlapp = Nothing
Db.Close
Set Db = Nothing |
Partager