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 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
|
Option Compare Database
Public Function alloc(BB_bro As Long)
Dim mois_debut As Long
Dim annee_debut As Long
Dim BB_choisi As String
Dim frm As Form
Dim nb_mois As Long
Set frm = CreateForm()
If BB_bro = 0 Then
frm.Section(0).BackColor = RGB(190, 255, 255)
Else
frm.Section(0).BackColor = RGB(255, 204, 153)
DoCmd.Close acForm, "Formulaire1", acSaveNo
End If
If Not IsNull(Forms("Gestion_alloc").Controls("mois_debut").Value) And Not IsNull(Forms("Gestion_alloc").Controls("annee_debut").Value) And Not IsNull(Forms("Gestion_alloc").Controls("BB_choisi").Value) Then
mois_debut = Forms("Gestion_alloc").Controls("mois_debut").Value
annee_debut = Forms("Gestion_alloc").Controls("annee_debut").Value
BB_choisi = Forms("Gestion_alloc").Controls("BB_choisi").Value
nb_mois = Forms("Gestion_alloc").Controls("nb_mois").Value
Else:
MsgBox "Erreur de saisie de données"
DoCmd.Close acForm, frm.Name, acSaveNo
GoTo Sortie
End If
recopie_PDP mois_debut, annee_debut, nb_mois, BB_choisi
entete mois_debut, annee_debut, nb_mois, BB_choisi, BB_bro, frm
ecriture mois_debut, annee_debut, nb_mois, BB_choisi, BB_bro, frm
DoCmd.OpenForm frm.Name, , , stLinkCriteria
Sortie:
End Function
'Entête de la page
Public Function entete(mois_debut As Variant, annee_debut As Variant, nb_mois As Variant, BB As Variant, BB_bro As Variant, frm As Variant)
Dim ctr_annee(1 To 3) As Control
Dim ctr_mois(1 To 24) As Control
Dim ctr_pdp(1 To 24) As Control
Dim ctr_alloue(1 To 24) As Control
Dim ctr_stock(1 To 24) As Control
Dim ctr_mois_all(1 To 24) As Control
Dim ctr_entete(1 To 6) As Control
Dim ctr_color(1 To 10) As Control
Dim i As Long
Dim haut, decallage, decal_haut, gauche As Long
Dim mois_en_cours, mois_all As Long
Dim annee_en_cours As Long
Dim hauteur, largeur, toptop As Long
Dim db As DAO.Database
Dim rst_PDP As Recordset
Dim nb_field As Long
Dim ctr_quit As Control
Dim c1, c2 As Boolean
Set db = CurrentDb()
hauteur = 250
largeur = 500
decallage = 100
gauche = 5000
decal_haut = 50
toptop = 500
c1 = True
c2 = True
mois_en_cours = mois_debut
If mois_en_cours + 1 > 12 Then
mois_all = 1
c2 = Not c2
Else
mois_all = mois_en_cours + 1
End If
annee_en_cours = annee_debut
Set ctr_annee(1) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
Set ctr_annee(2) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
Set ctr_annee(3) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
ctr_annee(1).Left = gauche
ctr_annee(1).Caption = annee_en_cours
ctr_annee(1).Top = toptop
ctr_annee(1).TextAlign = 2
ctr_annee(1).BorderStyle = 1
ctr_annee(1).BackStyle = 1
ctr_annee(1).BackColor = RGB(255, 255, 255)
ctr_annee(2).Caption = annee_en_cours + 1
ctr_annee(2).Top = toptop
ctr_annee(2).TextAlign = 2
ctr_annee(2).BorderStyle = 1
ctr_annee(2).BackStyle = 1
ctr_annee(2).BackColor = RGB(255, 255, 255)
ctr_annee(3).Caption = annee_en_cours + 2
ctr_annee(3).Top = toptop
ctr_annee(3).TextAlign = 2
ctr_annee(3).BorderStyle = 1
ctr_annee(3).BackStyle = 1
ctr_annee(3).BackColor = RGB(255, 255, 255)
For i = 1 To nb_mois
Set rst_PDP = db.OpenRecordset("SELECT * FROM T_alloc where T_alloc.Mois = " & mois_en_cours & " and T_alloc.Annee = " & annee_en_cours & " ")
Set ctr_mois(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
Set ctr_mois_all(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
Set ctr_pdp(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
Set ctr_alloue(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
Set ctr_stock(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, hauteur)
ctr_mois(i).Name = "Mois_en_cours_" & i
ctr_mois_all(i).Name = "Mois_all_" & i
ctr_pdp(i).Name = "Pdp_" & i
ctr_alloue(i).Name = "Alloue_" & i
ctr_stock(i).Name = "Stock_" & i
ctr_mois(i).Left = gauche + ((i - 1) * ctr_mois(i).Width) + decallage * (i - 1)
ctr_pdp(i).Left = gauche + ((i - 1) * ctr_pdp(i).Width) + decallage * (i - 1)
ctr_mois_all(i).Left = gauche + ((i - 1) * ctr_mois_all(i).Width) + decallage * (i - 1)
ctr_alloue(i).Left = gauche + ((i - 1) * ctr_alloue(i).Width) + decallage * (i - 1)
ctr_stock(i).Left = gauche + ((i - 1) * ctr_stock(i).Width) + decallage * (i - 1)
ctr_mois(i).Top = ctr_annee(1).Top + ctr_annee(1).Height + decal_haut
ctr_pdp(i).Top = ctr_mois(i).Top + ctr_mois(i).Height + decal_haut
ctr_alloue(i).Top = ctr_pdp(i).Top + ctr_pdp(i).Height + decal_haut
ctr_stock(i).Top = ctr_alloue(i).Top + ctr_alloue(i).Height + decal_haut
ctr_mois_all(i).Top = ctr_stock(i).Top + ctr_stock(i).Height + decal_haut
ctr_mois(i).Caption = mois_en_cours
ctr_pdp(i).Caption = rst_PDP.Fields(3).Value
ctr_alloue(i).Caption = "0"
ctr_stock(i).Caption = ctr_pdp(i).Caption
ctr_mois_all(i).Caption = mois_all
ctr_mois(i).TextAlign = 2
ctr_pdp(i).TextAlign = 2
ctr_alloue(i).TextAlign = 2
ctr_stock(i).TextAlign = 2
ctr_mois_all(i).TextAlign = 2
ctr_mois(i).BorderStyle = 1
ctr_pdp(i).BorderStyle = 1
ctr_alloue(i).BorderStyle = 1
ctr_stock(i).BorderStyle = 1
ctr_mois_all(i).BorderStyle = 1
ctr_mois(i).BackStyle = 1
If c1 Then ctr_mois(i).BackColor = RGB(255, 255, 0) Else ctr_mois(i).BackColor = RGB(255, 204, 0)
ctr_mois_all(i).BackStyle = 1
If c2 Then ctr_mois_all(i).BackColor = RGB(255, 255, 0) Else ctr_mois_all(i).BackColor = RGB(255, 204, 0)
If annee_en_cours = annee_debut Then ctr_annee(1).Width = (ctr_mois(i).Width + decallage) * (i) - decallage
If mois_en_cours + 1 > 12 And annee_en_cours = annee_debut Then
mois_en_cours = 1
annee_en_cours = annee_en_cours + 1
c1 = Not c1
ctr_annee(2).Left = (ctr_mois(i).Width + decallage) * (i) + gauche
ctr_annee(3).Visible = False
If (ctr_mois(i).Width + decallage) * (nb_mois - i) - decallage > 0 Then
ctr_annee(2).Width = (ctr_mois(i).Width + decallage) * (nb_mois - i) - decallage
Else
ctr_annee(2).Visible = False
End If
Else
If mois_en_cours + 1 > 12 And annee_en_cours > annee_debut Then
mois_en_cours = 1
annee_en_cours = annee_en_cours + 1
c1 = Not c1
ctr_annee(2).Width = (ctr_mois(i).Width + decallage) * (12) - decallage
ctr_annee(2).Visible = True
ctr_annee(3).Left = (ctr_mois(i).Width + decallage) * (i) + gauche
ctr_annee(3).Visible = True
If (ctr_mois(i).Width + decallage) * (nb_mois - i) - decallage > 0 Then
ctr_annee(3).Width = (ctr_mois(i).Width + decallage) * (nb_mois - i) - decallage
Else
ctr_annee(3).Visible = False
End If
Else
mois_en_cours = mois_en_cours + 1
End If
End If
If mois_en_cours + 1 > 12 Then
mois_all = 1
c2 = Not c2
Else
mois_all = mois_en_cours + 1
End If
Next
For i = 1 To 6
Set ctr_entete(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur * 3, hauteur)
ctr_entete(i).Name = "Entete_" & i
ctr_entete(i).Left = gauche - decallage - ctr_entete(i).Width
ctr_entete(i).Top = toptop + (decal_haut + ctr_entete(i).Height) * (i - 1)
ctr_entete(i).TextAlign = 3
Next
ctr_entete(1).Caption = "Année"
ctr_entete(2).Caption = "Mois de production"
ctr_entete(3).Caption = "Quantité produite"
ctr_entete(4).Caption = "Quantité allouée"
ctr_entete(5).Caption = "Stock"
ctr_entete(6).Caption = "Mois de délivrance"
For i = 1 To 9
Set ctr_color(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur * 2, hauteur)
If i < 6 Then
ctr_color(i).Left = decallage * 3
ctr_color(i).Top = toptop + (decal_haut + ctr_color(i).Height) * (i - 1)
Else
ctr_color(i).Left = (gauche - decallage - ctr_entete(1).Width) / 2
ctr_color(i).Top = toptop + (decal_haut + ctr_color(i).Height) * (i - 6)
End If
ctr_color(i).TextAlign = 2
ctr_color(i).BorderStyle = 1
ctr_color(i).BackStyle = 1
ctr_color(i).Name = "Color_" & i
Next
ctr_color(1).Caption = "GM200M"
ctr_color(1).BackColor = RGB(255, 204, 255)
ctr_color(2).Caption = "GM200F"
ctr_color(2).BackColor = RGB(204, 102, 204)
ctr_color(3).Caption = "GM403F"
ctr_color(3).BackColor = RGB(153, 255, 153)
ctr_color(4).Caption = "GM403M"
ctr_color(4).BackColor = RGB(51, 204, 0)
ctr_color(5).Caption = "GM406M"
ctr_color(5).BackColor = RGB(255, 204, 153)
ctr_color(6).Caption = "GM406F"
ctr_color(6).BackColor = RGB(255, 153, 0)
ctr_color(7).Caption = "GS100"
ctr_color(7).BackColor = RGB(51, 204, 255)
ctr_color(8).Caption = "GM60"
ctr_color(8).BackColor = RGB(102, 102, 204)
ctr_color(9).Caption = "SM400"
ctr_color(9).BackColor = RGB(204, 102, 0)
Set ctr_quit = CreateControl(frm.Name, acCommandButton, , "", "", 500, 500, 1000, 500)
ctr_quit.Left = ctr_mois(nb_mois).Left + ctr_mois(nb_mois).Width + decallage
ctr_quit.Top = toptop / 2
ctr_quit.Name = "ctr_quit"
ctr_quit.Caption = "Quitter"
If BB_bro = 0 Then
ctr_quit.OnClick = "=Quitter()"
Else
ctr_quit.OnClick = "=Quitter4( " & 2 & " )"
End If
End Function
Public Function recopie_PDP(mois_debut As Variant, annee_debut As Variant, nb_mois As Variant, BB_choisi As Variant)
Dim db As DAO.Database
Dim rst_PDP As DAO.Recordset
Dim mois_en_cours, annee_en_cours As Long
Dim nb_field As Long
Set db = CurrentDb()
DoCmd.SetWarnings False
DoCmd.RunSQL ("DELETE * FROM T_alloc")
DoCmd.SetWarnings True
Select Case BB_choisi
Case "SGBB"
nb_field = 2
Case "Tx Rack"
nb_field = 3
Case "Rx Tile"
nb_field = 4
Case "Back End"
nb_field = 5
Case "Front End"
nb_field = 6
Case "RX Panels"
nb_field = 7
Case "TX Panels"
nb_field = 8
End Select
mois_en_cours = mois_debut
annee_en_cours = annee_debut
For i = 1 To nb_mois
Set rst_PDP = db.OpenRecordset("SELECT * FROM T_PDP where T_PDP.mois = " & mois_en_cours & " and T_PDP.année = " & annee_en_cours & " ")
Set rst_T_alloc = db.OpenRecordset("T_alloc", dbOpenDynaset)
rst_T_alloc.AddNew
rst_T_alloc.Fields(0).Value = i
rst_T_alloc.Fields(1).Value = mois_en_cours
rst_T_alloc.Fields(2).Value = annee_en_cours
rst_T_alloc.Fields(3).Value = rst_PDP.Fields(nb_field).Value
rst_T_alloc.Update
If mois_en_cours + 1 > 12 Then
mois_en_cours = 1
annee_en_cours = annee_en_cours + 1
Else
mois_en_cours = mois_en_cours + 1
End If
Next
End Function
Public Function Quitter4(num_form As Long)
DoCmd.Close acForm, "Formulaire" & num_form, acSaveNo
alloc 0
End Function
'Fonction d'écriture des blocs de building blocs
Public Function ecriture(mois_debut As Variant, annee_debut As Variant, nb_mois As Variant, BB_choisi As Variant, BB_bro As Variant, frm As Variant)
Dim db As DAO.Database
Dim rstSQL_recherche As DAO.Recordset
Dim rst_aff As DAO.Recordset
Dim toptop, decal_haut As Long
Dim date_debut, date_fin As Long
Dim haut, decallage, gauche As Long
Dim i, id, j As Long
Dim aff As String
Dim ctr_fiche(1 To 50) As Control
Dim ctr_affaire(1 To 50) As Control
Dim ctr_BB_S(1 To 50) As Control
Dim ctr_scenario(1 To 50) As Control
Dim ctr_Q(1 To 50) As Control
Dim ctr_date(1 To 50) As Control
Dim ctr_plus(1 To 50) As Control
Dim ctr_demandeur_mois(1 To 50) As Control
Dim ctr_demandeur_annee(1 To 50) As Control
Dim ctr_valid(1 To 50) As Control
Dim ctr_BB(1 To 50) As Control
Dim largeur As Long
Dim d, d1 As Date
Dim k1, k2 As Long
decal_haut = 50
'On définit des variables de mise en forme
haut = 2300
decallage = 100
gauche = 100
i = 1
aff = ""
id = 0
j = 1
largeur = 500
date_debut = mois_debut + annee_debut * 12
date_fin = date_debut + nb_mois
Set db = CurrentDb
'On définit la requêtes SQL de recherche selon les cas (par bloc ou éclaté, par affaire ou produit)
If BB_bro = 0 Then
Set rstSQL_recherche = db.OpenRecordset("SELECT * From T_BB where T_BB.BB_S = '" & BB_choisi & "' and Year(T_BB.Date) * 12 + Month(T_BB.Date) >= " & date_debut & " and Year(T_BB.Date) * 12 + Month(T_BB.Date) < " & date_fin & " Order by T_BB.Date, T_BB.id_pdt ") '
Else
Set rstSQL_recherche = db.OpenRecordset("SELECT * From T_BB where T_BB.BB_S = '" & BB_choisi & "' and T_BB.BB_bro = " & BB_bro & " and Year(T_BB.Date) * 12 + Month(T_BB.Date) >= " & date_debut & " and Year(T_BB.Date) * 12 + Month(T_BB.Date) < " & date_fin & " Order by T_BB.Date, T_BB.id_pdt ") '
End If
'On va créer tous les contôles
Do While Not rstSQL_recherche.EOF And i < 50
'Tout d'abord on regarde, dans le cas d'un affichage par blocs, si le BB a déja un "brother", et dans
'ce cas on ne crée pas de ligne mais on ajoute sa quantité
If IsNull(rstSQL_recherche.Fields(16).Value) Then
rstSQL_recherche.Edit
rstSQL_recherche.Fields(16).Value = rstSQL_recherche.Fields(5).Value
rstSQL_recherche.Update
End If
If rstSQL_recherche.Fields(7).Value = aff And rstSQL_recherche.Fields(5).Value = d And rstSQL_recherche.Fields(16).Value = d1 And BB_bro = 0 Then
ctr_Q(i - 1).Caption = ctr_Q(i - 1).Caption + 1
ctr_BB(i - 1).Caption = ctr_Q(i - 1).Caption
rstSQL_recherche.Edit
rstSQL_recherche.Fields(21).Value = id
rstSQL_recherche.Update
ctr_plus(i - 1).Visible = True
Else
'Création des différents contrôles et boutons
Set ctr_fiche(i) = CreateControl(frm.Name, acCommandButton, , "", "", 500, 500, 400, 250)
Set ctr_affaire(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, 1000, 250)
Set ctr_BB_S(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, 1000, 250)
Set ctr_Q(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, 300, 250)
Set ctr_date(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, 1000, 250)
Set ctr_plus(i) = CreateControl(frm.Name, acCommandButton, , "", "", 500, 500, 400, 250)
Set ctr_demandeur_mois(i) = CreateControl(frm.Name, acTextBox, , "", "", 500, 500, 300, 250)
Set ctr_demandeur_annee(i) = CreateControl(frm.Name, acTextBox, , "", "", 500, 500, 600, 250)
Set ctr_valid(i) = CreateControl(frm.Name, acCommandButton, , "", "", 500, 500, 400, 250)
Set ctr_BB(i) = CreateControl(frm.Name, acLabel, , "", "", 500, 500, largeur, 250)
'On affecte un nom aux contrôles pour pouvoir les appeler plus loin
ctr_fiche(i).Name = "Fiche_" & rstSQL_recherche.Fields(0).Value
ctr_affaire(i).Name = "Affaire_" & rstSQL_recherche.Fields(0).Value
ctr_BB_S(i).Name = "BB_S_" & rstSQL_recherche.Fields(0).Value
ctr_Q(i).Name = "Q_" & rstSQL_recherche.Fields(0).Value
ctr_date(i).Name = "Date_" & rstSQL_recherche.Fields(0).Value
ctr_plus(i).Name = "Plus_" & rstSQL_recherche.Fields(0).Value
ctr_demandeur_mois(i).Name = "Mois_" & rstSQL_recherche.Fields(0).Value
ctr_demandeur_annee(i).Name = "Annee_" & rstSQL_recherche.Fields(0).Value
ctr_valid(i).Name = "Valid_" & rstSQL_recherche.Fields(0).Value
ctr_BB(i).Name = "BB_" & rstSQL_recherche.Fields(0).Value
'On les place par rapport à la gauche de la page
ctr_fiche(i).Left = gauche
ctr_affaire(i).Left = gauche + ctr_fiche(i).Left + ctr_fiche(i).Width
ctr_BB_S(i).Left = decallage + ctr_affaire(i).Left + ctr_affaire(i).Width
ctr_Q(i).Left = decallage + ctr_BB_S(i).Left + ctr_BB_S(i).Width
ctr_date(i).Left = decallage + ctr_Q(i).Left + ctr_Q(i).Width
ctr_plus(i).Left = decallage + ctr_date(i).Left + ctr_date(i).Width
ctr_demandeur_mois(i).Left = decallage + Forms(frm.Name).Controls("Mois_en_cours_" & nb_mois).Left + Forms(frm.Name).Controls("Mois_en_cours_" & nb_mois).Width
ctr_demandeur_annee(i).Left = decallage + ctr_demandeur_mois(i).Left + ctr_demandeur_mois(i).Width
ctr_valid(i).Left = decallage + ctr_demandeur_annee(i).Left + ctr_demandeur_annee(i).Width
'Et au haut de la page
ctr_fiche(i).Top = haut + i * 300
ctr_affaire(i).Top = haut + i * 300
ctr_BB_S(i).Top = haut + i * 300
ctr_Q(i).Top = haut + i * 300
ctr_date(i).Top = haut + i * 300
ctr_plus(i).Top = haut + i * 300
ctr_demandeur_mois(i).Top = haut + i * 300
ctr_demandeur_annee(i).Top = haut + i * 300
ctr_valid(i).Top = haut + i * 300
ctr_BB(i).Top = haut + i * 300
'On leur met ici diverses propriétés : du texte, des listes de valeurs...
ctr_fiche(i).Caption = "o"
Set rst_aff = db.OpenRecordset("Select * from T_Prod_Prog where T_Prod_Prog.id_pdt = " & rstSQL_recherche.Fields(1).Value & " ")
ctr_affaire(i).Caption = rst_aff.Fields(1).Value & " " & rst_aff.Fields(4).Value
ctr_BB_S(i).Caption = rstSQL_recherche.Fields(2).Value
ctr_Q(i).Caption = "1"
ctr_BB(i).Caption = ctr_Q(i).Caption
ctr_BB(i).BorderStyle = 1
ctr_BB(i).BackStyle = 1
ctr_BB(i).BackColor = RGB(255, 255, 255)
ctr_BB(i).TextAlign = 2
ctr_BB(i).FontBold = True
Select Case rstSQL_recherche.Fields(24).Value
Case "GM 200 Mobile"
ctr_BB(i).BackColor = RGB(255, 204, 255)
Case "GM 200 Fixe"
ctr_BB(i).BackColor = RGB(204, 102, 204)
Case "GM 403 Fixe"
ctr_BB(i).BackColor = RGB(153, 255, 153)
Case "GM 403 Mobile"
ctr_BB(i).BackColor = RGB(51, 204, 0)
Case "GM 406 Mobile"
ctr_BB(i).BackColor = RGB(255, 204, 153)
Case "GM 406 Fixe"
ctr_BB(i).BackColor = RGB(255, 153, 0)
Case "GS100"
ctr_BB(i).BackColor = RGB(51, 204, 255)
Case "GM60"
ctr_BB(i).BackColor = RGB(102, 102, 204)
Case "SM 400"
ctr_BB(i).BackColor = RGB(204, 102, 0)
End Select
'S'il manque une date à un BB, on annule le process et on sort du formulaire. La fonction
'quitter est dans un autre module
If IsNull(rstSQL_recherche.Fields(5).Value) Then
MsgBox "Spécifiez la date des BB!"
Quitter
GoTo Sortie
Else
ctr_date(i).Caption = rstSQL_recherche.Fields(5).Value
End If
ctr_plus(i).Caption = "+"
ctr_plus(i).FontSize = 6
ctr_plus(i).Visible = False
ctr_plus(i).OnClick = "=alloc(" & rstSQL_recherche.Fields(0).Value & ")"
If BB_bro = 0 Then ctr_fiche(i).OnClick = "=Fiche_BB(" & rstSQL_recherche.Fields(0).Value & "," & 2 & ")" Else ctr_fiche(i).OnClick = "=Fiche_BB(" & rstSQL_recherche.Fields(0).Value & "," & 1 & ")"
ctr_fiche(i).FontSize = 6
ctr_date(i).BackStyle = 1
ctr_date(i).BackColor = RGB(51, 255, 51)
ctr_Q(i).BackStyle = 1
ctr_Q(i).BackColor = RGB(255, 153, 255)
ctr_Q(i).TextAlign = 2
ctr_BB_S(i).TextAlign = 2
ctr_date(i).TextAlign = 2
ctr_valid(i).Caption = "v"
ctr_valid(i).FontSize = 6
If BB_bro = 0 Then ctr_valid(i).OnClick = "=valid(" & rstSQL_recherche.Fields(0).Value & "," & 1 & ")" Else ctr_valid(i).OnClick = "=Supprim(" & rstSQL_recherche.Fields(0).Value & "," & 2 & ")"
id = rstSQL_recherche.Fields(0).Value
If BB_bro = 0 Then
rstSQL_recherche.Edit
rstSQL_recherche.Fields(21).Value = id
rstSQL_recherche.Update
End If
If Not IsNull(rstSQL_recherche.Fields(16).Value) Then
ctr_demandeur_mois(i).DefaultValue = Month(rstSQL_recherche.Fields(16).Value)
ctr_demandeur_annee(i).DefaultValue = Year(rstSQL_recherche.Fields(16).Value)
End If
'On calle le control ctr_BB
k1 = mois_debut
k2 = annee_debut
For j = 1 To nb_mois
'MsgBox k1 & " " & Month(rstSQL_recherche.Fields(16).Value) & " " & k2 & " " & Year(rstSQL_recherche.Fields(16).Value)
If k1 = Month(rstSQL_recherche.Fields(16).Value) And k2 = Year(rstSQL_recherche.Fields(16).Value) Then
ctr_BB(i).Left = Forms(frm.Name).Controls("Mois_en_cours_" & j).Left
Exit For
End If
If k1 + 1 > 12 Then
k1 = 1
k2 = k2 + 1
Else:
k1 = k1 + 1
End If
Next
i = i + 1
End If
aff = rstSQL_recherche.Fields(7).Value
d = rstSQL_recherche.Fields(5).Value
d1 = rstSQL_recherche.Fields(16).Value
rstSQL_recherche.MoveNext
Loop
If i = 49 Then MsgBox "Nombre de mois trop important. Veuillez diminuer ce nombre."
Sortie:
rstSQL_recherche.Close
Set rstSQL_recherche = Nothing
End Function |