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
|
Option Compare Database
Function ecriture_personne(type_statut As String)
'déclaration des variables
Dim base_de_donne As Database
Dim selection_personne As DAO.Recordset
Dim nombre_personne As Integer
'récupère les différentes informations relatives au personnes présentes, absentes, ...
Set base_de_donne = CurrentDb
'requete SQL qui va rechercher le président
Set selection_personne = base_de_donne.OpenRecordset("SELECT nom_personne, prenom_personne FROM tbl_personne, tbl_pv, tbl_type_statut, rel_pv_personne_type_statut WHERE tbl_pv.id_pv = rel_pv_personne_type_statut.id_pv AND tbl_type_statut.id_type_statut = rel_pv_personne_type_statut.id_type_statut AND tbl_personne.id_personne = rel_pv_personne_type_statut.id_personne AND tbl_type_statut.description_type_statut = '" & type_statut & "' And tbl_pv.id_pv = " & Form_frm_pv.txt_id_pv.Value)
'initialisation du nombre de personne
nombre_personne = 0
'écrit le nom de la personne plus la première lettre de son prénom
While Not selection_personne.EOF
nombre_personne = nombre_personne + 1
If nombre_personne <> 1 Then
Selection.TypeText Text:=", " & selection_personne("nom_personne") & " " & Left(selection_personne("prenom_personne"), 1) & "."
Else
Selection.TypeText Text:=selection_personne("nom_personne") & " " & Left(selection_personne("prenom_personne"), 1) & "."
End If
selection_personne.MoveNext
Wend
End Function
Function ecriture_titre(id_titre As Integer)
'déclaration des variables
Dim description_titre As String
Dim nombre_sous_titre As Integer
'récupère la description du titre
description_titre = DLookup("description_titre", "tbl_titre", "id_titre = " & id_titre)
'récupère le nombre de sous-titre
nombre_sous_titre = DLookup("count(id_sous_titre)", "tbl_sous_titre", "id_titre = " & id_titre)
'fonction qui créé le tableau dans lequel il y aura les titres et les sous-titres
'insertion du tableau
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=(nombre_sous_titre * 2) + 1, NumColumns:=5, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
'redéfinit la largeur des colonnes
Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=266, RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(2).SetWidth ColumnWidth:=18, RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=63, RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(4).SetWidth ColumnWidth:=63, RulerStyle:=wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=58, RulerStyle:=wdAdjustNone
'fusionne la cellule de titre et inscrit la valeur à l'intérieur
Selection.MoveRight Unit:=wdWord, Count:=6, Extend:=wdExtend
Selection.Style = ActiveDocument.Styles("Titre 1")
Selection.Cells.Merge
Selection.TypeText Text:=description_titre
Selection.MoveRight Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
'met la première ligne du tableau en noir avec la police en blanc
With Selection.Cells
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorBlack
End With
End With
Selection.Font.Color = wdColorWhite
'dessends à la cellule en dessous
Selection.MoveDown
'appel la fonction pour l'écriture des sous-titre
Call ecriture_sous_titre(id_titre)
End Function
Function ecriture_sous_titre(id_titre As Integer)
'déclaration des variables
Dim base_de_donne As Database
Dim selection_sous_titre As DAO.Recordset
'récupère les différentes informations des sous-titres
Set base_de_donne = CurrentDb
'requete SQL qui va rechercher le président
Set selection_sous_titre = base_de_donne.OpenRecordset("SELECT DISTINCT tbl_sous_titre.titre_sous_titre, tbl_sous_titre.description_sous_titre, tbl_etat.description_etat, tbl_personne.nom_personne, tbl_personne.prenom_personne, tbl_type_sous_titre.description_type_sous_titre, tbl_sous_titre.delai_sous_titre FROM tbl_etat INNER JOIN (tbl_type_sous_titre INNER JOIN (tbl_sous_titre INNER JOIN (tbl_personne INNER JOIN rel_personne_sous_titre ON tbl_personne.id_personne = rel_personne_sous_titre.id_personne) ON tbl_sous_titre.id_sous_titre = rel_personne_sous_titre.id_sous_titre) ON tbl_type_sous_titre.id_type_sous_titre = tbl_sous_titre.id_type_sous_titre) ON tbl_etat.id_etat = tbl_sous_titre.id_etat WHERE tbl_sous_titre.id_titre = " & id_titre)
'écrit le nom de la personne plus la première lettre de son prénom
While Not selection_sous_titre.EOF
'inscription du titre du sous-titre
Selection.TypeText Text:=selection_sous_titre("titre_sous_titre")
Selection.MoveRight
'inscription du titre de la description
Selection.TypeText Text:=Left(selection_sous_titre("description_type_sous_titre"), 1)
Selection.MoveRight
'inscription du titre de la/les personnes
Selection.TypeText Text:=Left(selection_sous_titre("nom_personne"), 1) & "" & Left(selection_sous_titre("prenom_personne"), 1)
Selection.MoveRight
'inscription du délai
'controle qu'il y a bien un délai
If Not IsNull(selection_sous_titre("delai_sous_titre")) Then
Selection.TypeText Text:=selection_sous_titre("delai_sous_titre")
End If
Selection.MoveRight
'inscription du titre de l'état
Selection.TypeText Text:=selection_sous_titre("description_etat")
Selection.MoveRight Unit:=wdCell, Count:=1
'inscription du titre de la description
Selection.MoveRight Unit:=wdWord, Count:=6, Extend:=wdExtend
Selection.Cells.Merge
Selection.TypeText Text:=selection_sous_titre("description_sous_titre")
'va à la prochaine ligne
Selection.MoveRight
selection_sous_titre.MoveNext
Wend
End Function |
Partager