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
| Public WithEvents appWord As Word.Application
Private Sub Enregistrer_Click()
'Enregistrement du fichier CRE sous
'Contrôle de contenu
'Enregistrement dans la BDD
'... Déclaration des Objets VBA
Dim controle As ContentControl
Dim adoConn As ADODB.Connection
Dim adoCmd As ADODB.Command
'... Récupération des champs textes
CPO = CPO.Value 'Commande client
DesOfMat = DesOfMat.Value 'Désignation du matériel
SN = SN.Value 'Numéro de série
Customer = Customer.Value 'Client
Operator = Operator.Value 'Utilisateur
OperatorCode = OperatorCode.Value 'Code utilisateur
MSNNumber = MSNNumber.Value 'Numéro avion
MSNRegistration = MSNRegistration.Value 'Immatriculation avion
AircraftModel = AircraftModel.Value 'Modèle avion
Ordre = OF.Value 'Ordre de réparation
Removal = Removal.Value 'Raison de dépose
TSN = TSN.Value 'Cycles de fonctionnement
CSN = CSN.Value
TSO = TSO.Value 'Temps depuis dernier passage en atelier
CSO = CSO.Value
TSI = TSI.Value
CSI = CSI.Value
PNOUT = PNOUT.Value
If Retour = True Then
DOLRIS = DOLRIS.Value 'Date du report
Else
DOLRIS = ""
End If
'... Récupération des contrôles de contenus de type Sélection de date ou Liste de choix
For Each controle In ActiveDocument.ContentControls
Select Case controle.Title
Case "NumCRE" 'Nomage CRE
NumCRE = controle.Range.Text
Case "PN" 'Référence
With controle
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
PN = .Range.Text
Exit For
End If
Next
End With
Case "RT" 'Type de dépose
With controle
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
RT = .Range.Text
Exit For
End If
Next
End With
Case "AircraftEIS" 'Date de l'avion
AircraftEIS = controle.Range.Text
Case "MRD" 'Date de réception
MRD = controle.Range.Text
Case "RemovalDate" 'Date de dépose
RemovalDate = controle.Range.Text
Case "TSLR" 'Date de fabrication
TSLR = controle.Range.Text
Case "CaractRayures" 'Caractéristique rayure constatée à la réception sur corps de verin
CaractRayures = controle.Range.Text
Case "DOLRIS" 'Date de retour
DOLRIS = controle.Range.Text
Case "RRC" 'Raison de dépose confirmée
RRC = controle.Range.Text
Case "ElectricalTestDesc" 'Description Test Electrique
ElectricalTestDesc = controle.Range.Text
Case "FunctionalTestDesc" 'Description Test Fonctionel
FunctionalTestDesc = controle.Range.Text
Case "CaractRayuresFind" 'Caractéristique rayure constatée au démontage sur corps de verin
CaractRayuresFind = controle.Range.Text
Case "CaractMainPiston" 'Caractéristique piston principal endomagé constaté au démontage
CaractMainPiston = controle.Range.Text
Case "CBSA" 'Documentation technique
CBSA = controle.Range.Text
Case "PTD" 'Documentation technique du produit
PTD = controle.Range.Text
Case "Status" 'Type de dépose
With controle
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
Status = .Range.Text
Exit For
End If
Next
End With
Case "StatusDes" 'Commentaire status
StatusDes = controle.Range.Text
Case "WHO" 'Auteur
WHO = controle.Range.Text
Case "CreateDate" 'Date de création
CreateDate = controle.Range.Text
Case "WARRANTY" 'Type de dépose
With controle
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
WARRANTY = .Range.Text
Exit For
End If
Next
End With
Case "Comment" 'Commentaire status
Comment = controle.Range.Text
Case "Conclusion" 'Commentaire status
Conclusion = controle.Range.Text
' Case "RepairCost" 'Type de dépose
' With controle
' For i = 1 To .DropdownListEntries.Count
' If .DropdownListEntries(i).Text = .Range.Text Then
' RepairCost = .Range.Text
' Exit For
' End If
' Next
' End With
Case Else
End Select
Next
'... Défauts Réception sélectionnés
DefReception1 = ""
DefReception2 = ""
DefReception3 = ""
DefReception4 = ""
DefReception5 = ""
DefReception6 = ""
DefReception7 = ""
DefReception8 = ""
DefReception9 = ""
DefReception10 = ""
DefReception11 = ""
DefReception12 = ""
DefReception13 = ""
DefReception14 = ""
DefReception15 = ""
If DefautReception1 = True Then
DefReception1 = DefautReception1.Caption
End If
If DefautReception2 = True Then
DefReception2 = DefautReception2.Caption
End If
If DefautReception3 = True Then
DefReception3 = DefautReception3.Caption
End If
If DefautReception4 = True Then
DefReception4 = DefautReception4.Caption
End If
If DefautReception5 = True Then
DefReception5 = DefautReception5.Caption
End If
If DefautReception6 = True Then
DefReception6 = DefautReception6.Caption
End If
If DefautReception7 = True Then
DefReception7 = DefautReception7.Caption
End If
If DefautReception8 = True Then
DefReception8 = DefautReception8.Caption
End If
If DefautReception9 = True Then
DefReception9 = DefautReception9.Caption
End If
If DefautReception10 = True Then
DefReception10 = DefautReception10.Caption
End If
If DefautReception11 = True Then
DefReception11 = DefautReception11.Caption
End If
If DefautReception12 = True Then
DefReception12 = DefautReception12.Caption
End If
If DefautReception13 = True Then
DefReception13 = DefautReception13.Caption
End If
If DefautReception14 = True Then
DefReception14 = DefautReception14.Caption
End If
If DefautReception15 = True Then
DefReception15 = DefautReception15.Caption
End If
'... Tests à réaliser ou pas
ElecTest = ""
FuncTest = ""
If ElectricalTestNA = True Then 'Test électrique
ElecTest = "N/A"
End If
If ElectricalTest = True Then
ElecTest = "Réalisé"
End If
If FunctionalTestNA = True Then 'Test fonctionnel
FuncTest = "N/A"
End If
If FunctionalTest = True Then
FuncTest = "Réalisé"
End If
'Autres constatations saisies
Find1 = ""
Find2 = ""
Find3 = ""
Find4 = ""
Find5 = ""
Find6 = ""
Find7 = ""
Find8 = ""
Find9 = ""
Find10 = ""
Find11 = ""
Find12 = ""
Find13 = ""
Find14 = ""
Find15 = ""
Find16 = ""
Find17 = ""
Find18 = ""
Find19 = ""
Find20 = ""
Find21 = ""
Find22 = ""
If Finding1 = True Then
Find1 = Finding1.Caption
End If
If Finding2 = True Then
Find2 = Finding2.Caption
End If
If Finding3 = True Then
Find3 = Finding3.Caption
End If
If Finding4 = True Then
Find4 = Finding4.Caption
End If
If Finding5 = True Then
Find5 = Finding5.Caption
End If
If Finding6 = True Then
Find6 = Finding6.Caption
End If
If Finding7 = True Then
Find7 = Finding7.Caption
End If
If Finding8 = True Then
Find8 = Finding8.Caption
End If
If Finding9 = True Then
Find9 = Finding9.Caption
End If
If Finding10 = True Then
Find10 = Finding10.Caption
End If
If Finding11 = True Then
Find11 = Finding11.Caption
End If
If Finding12 = True Then
Find12 = Finding12.Caption
End If
If Finding13 = True Then
Find13 = Finding13.Caption
End If
If Finding14 = True Then
Find14 = Finding14.Caption
End If
If Finding15 = True Then
Find15 = Finding15.Caption
End If
If Finding16 = True Then
Find16 = Finding16.Caption
End If
If Finding17 = True Then
Find17 = Finding17.Caption
End If
If Finding18 = True Then
Find18 = Finding18.Caption
End If
If Finding19 = True Then
Find19 = Finding19.Caption
End If
If Finding20 = True Then
Find20 = Finding20.Caption
End If
If Finding21 = True Then
Find21 = Finding21.Caption
End If
If Finding22 = True Then
Find22 = Finding22.Caption
End If
'Cout réparation
ChargeRatier = ""
ChargeClient = ""
If CoutRF = True Then
ChargeRatier = "Oui"
Else
ChargeRatier = "Non"
End If
If CoutClient = True Then
ChargeClient = "Oui"
Else
ChargeClient = "Non"
End If
'... Vérifier que aucun champs ne soit vide
'... Alimentation de la table MSAccess CRE
Application.Selection.Expand wdLine
Set adoConn = New ADODB.Connection
With adoConn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=V:\s6_mqp\departement\F5\Prestation MQP Thomas Fernandez\AIRBUS\RMA FE396\Nouveau Formulaire CRE\FORMULAIRE CRE.mdb"
.Open
End With
Set adoCmd = New ADODB.Command
With adoCmd
.ActiveConnection = adoConn
.CommandText = "INSERT INTO CRE " _
& "(NumCRE, ReportDate, CPO, DesOfMat, PN, SN, Customer, Operator, OperatorCode, MSNNumber, MSNRegistration, AircraftModel, AircraftEIS, MRD, Ordre, Removal, RT, RemovalDate, TSN, CSN, " _
& "TSLR, TSO, CSO, TSI, CSI, DOLRIS, DefautReception1, DefautReception2, DefautReception3, DefautReception4, DefautReception5, CaractRayures, DefautReception6, DefautReception7, DefautReception8, " _
& "DefautReception9, DefautReception10, DefautReception11, DefautReception12, DefautReception13, DefautReception14, DefautReception15, " _
& "ElectricalTest, FunctionalTest, Finding1, Finding2, CaractRayuresFind, Finding3, Finding4, Finding5, CaractMainPiston, Finding6, Finding7, Finding8, Finding9, Finding10, Finding11, Finding12, Finding13, Finding14, " _
& "Finding15, Finding16, Finding17, Finding18, Finding19, Finding20, Finding21, Finding22, RRC, CBSA, PTD, Status, StatusDes, PNOUT, WHO, " _
& "CreateDate, WARRANTY, Comment, Conclusion, CoutRF, CoutClient) " _
& "VALUES ('" & NumCRE & "','" & ReportDate & "','" & CPO & "', '" & DesOfMat & "', '" & PN & "', '" & SN & "', '" & Customer & "', '" & Operator & "', '" & OperatorCode & "', '" & MSNNumber & "', '" _
& MSNRegistration & "', '" & AircraftModel & "', '" & AircraftEIS & "', '" & MRD & "', '" & Ordre & "', '" & Removal & "', '" & RT & "', '" & RemovalDate & "', '" & TSN & "', '" & CSN & "', '" _
& TSLR & "', '" & TSO & "', '" & CSO & "', '" & TSI & "', '" & CSI & "', '" & DOLRIS & "', '" & DefReception1 & "', '" & DefReception2 & "', '" & DefReception3 & "', '" & DefReception4 & "', '" _
& DefReception5 & "', '''" & CaractRayures & "''', '" & DefReception6 & "', '" & DefReception7 & "', '" & DefReception8 & "', '" & DefReception9 & "', '" & DefReception10 & "', '" & DefReception11 & "', '" & DefReception12 & "', '" _
& DefReception13 & "', '" & DefReception14 & "', '" & DefReception15 & "', '" _
& ElecTest & "', '" & FuncTest & "', '" & Find1 & "', '" & Find2 & "', '''" & CaractRayuresFind & "''', '" & Find3 & "', '" & Find4 & "', '" & Find5 & "', '''" & CaractMainPiston & "''', '" & Find6 & "', '" & Find7 & "', '" & Find8 & "', '" & Find9 & "', '" & Find10 & "', '" _
& Find11 & "', '" & Find12 & "', '" & Find13 & "', '" & Find14 & "', '" & Find15 & "', '" & Find16 & "', '" & Find17 & "', '" & Find18 & "', '" & Find19 & "', '" & Find20 & "', '" & Find21 & "', '" _
& Find22 & "', '" & RRC & "', '" & CBSA & "', '" & PTD & "', '" & Status & "', '''" _
& StatusDes & "', '" & PNOUT & "', '" & WHO & "', '" & CreateDate & "', '" & WARRANTY & " ''', '''" & Comment & " ''', '''" & Conclusion & "''', '" & ChargeRatier & "', '" & ChargeClient & "')"
End With
'Msgbox adoCmd.CommandText
adoCmd.Execute
adoConn.Close
Msgbox "Value was added to your database table."
'... Saves active doc in current folder named upon current time
Dim strTime As String
strTime = Format(Now, "hh-mm")
ActiveDocument.SaveAs FileName:=ActiveDocument.Path & "\" & NumCRE & "_" & strTime, FileFormat:=wdFormatDocument
'ActiveDocument.SaveAs FileName:="V:\S6MQP\...." & NumCRE & "_" & strTime, FileFormat:=wdFormatDocument
'... Delete all Object not fully completed
'... Libération des objets utilisés
Set controle = Nothing
Set adoConn = Nothing
Set adoCmd = Nothing
Set vbComp = Nothing
End Sub
'
'---------------- Actions VBA ----------------
'
Private Sub SN_Change()
ReportDate.Value = Format(Date, "mm/dd/yyyy")
For Each controle In ActiveDocument.ContentControls
If controle.Title = "PN" Then
With controle
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
PN = .Range.Text
Exit For
End If
Next
End With
End If
Next
For Each controle In ActiveDocument.ContentControls
If controle.Title = "NumCRE" Then
controle.Range.Text = PN & "_" & OF.Value & "_" & SN.Value
Exit For
End If
Next
End Sub
Private Sub OF_Change()
For Each controle In ActiveDocument.ContentControls
If controle.Title = "PN" Then
With controle
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
PN = .Range.Text
Exit For
End If
Next
End With
End If
Next
For Each controle In ActiveDocument.ContentControls
If controle.Title = "NumCRE" Then
controle.Range.Text = PN & "_" & OF.Value & "_" & SN.Value
End If
Next
End Sub
Private Sub Retour_Click()
If Retour = True Then
DOLRIS.Enabled = True
Else
DOLRIS.Enabled = False
DOLRIS.Value = "jj/mm/aaaa"
End If
End Sub |
Partager