Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access > IHM
IHM Ce forum est dédié aux questions relatives à la création de formulaires et d'états, avec ou sans code VBA, et macros.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 15/12/2010, 22h05   #1
Membre du Club
 
hugues dupont
Pompier
Inscription : janvier 2010
Messages : 170
Détails du profil
Informations personnelles :
Nom : hugues dupont
Localisation : France

Informations professionnelles :
Activité : Pompier

Informations forums :
Inscription : janvier 2010
Messages : 170
Points : 44
Points : 44
Par défaut mise en forme conditionnelle

bonjour voici mon petit problème
je suis sur un planning et pour chaque jour, les personnels ont plusieurs type de garde.
Avec la mise en forme conditionnelle, je suis limité à 3+1 conditions; hors j'en ai une bonne 10ène.
Il faut surement ce tourner vers le vba.
J'ai bien lu le tutoriel mais ça ne fonctionne pas.

ce que je voudrais c'est
si Jour1= "G" ou "J" ou "N" alors couleur de fond = jaune
si Jour1= "DG" ou "DJ" ou "DN" alors couleur de fond = orange
si Jour1="AT" ou "AM" ou "D" alors couleur de fond = violet
si Jour1="GF" ou "F" alors couleur de fond = vert

merci
hugodu28 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/12/2010, 08h19   #2
Rédacteur/Modérateur
 
Avatar de Jeannot45
 
Homme Jean BALLAT
Inscription : octobre 2004
Messages : 2 856
Détails du profil
Informations personnelles :
Nom : Homme Jean BALLAT
Âge : 63
Localisation : France, Loiret (Centre)

Informations forums :
Inscription : octobre 2004
Messages : 2 856
Points : 5 221
Points : 5 221


Dans la boite de dialogue de la mise en forme conditionnelle, tu peux utiliser le choix "Expression" et ainsi créer l'expression du type :

Code :
Jour1=  "G" ou Jour1=  "J" ou Jour1=  "N"
Il te reste à affecter la couleur de fond correspondante

bonne continuation
__________________
Jeannot

Liens Office indispensables à visiter: Cours (Tutos), F.A.Q., [B]Sources VBA

Ne posez pas de questions par MP, je n'ai pas le temps d'y répondre
Jeannot45 est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 16/12/2010, 11h57   #3
Membre éclairé
 
Homme Pierre-Jean
Développeur informatique
Inscription : février 2010
Messages : 306
Détails du profil
Informations personnelles :
Nom : Homme Pierre-Jean
Âge : 31
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : Industrie

Informations forums :
Inscription : février 2010
Messages : 306
Points : 330
Points : 330
Envoyer un message via MSN à paidge
Salut,

Ton planning est sous quelle forme ?
-Formulaire
-Etat
-Spreadsheet
....
paidge est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2010, 18h13   #4
Membre du Club
 
hugues dupont
Pompier
Inscription : janvier 2010
Messages : 170
Détails du profil
Informations personnelles :
Nom : hugues dupont
Localisation : France

Informations professionnelles :
Activité : Pompier

Informations forums :
Inscription : janvier 2010
Messages : 170
Points : 44
Points : 44
pour ce qui est d'utiliser la mise en formae automatique j'ai trop de containte (>4)

Mon planning est en formulaire et en état
j'aimerais si possible l'avoir pour l'état que je souhaite imprimer
si c'est possible pour le formulaire aussi , c'est la cerise sur le gâteau
hugodu28 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2010, 19h28   #5
Rédacteur/Modérateur
 
Avatar de User
 
Homme Denis
Développeur informatique
Inscription : août 2004
Messages : 3 204
Détails du profil
Informations personnelles :
Nom : Homme Denis
Âge : 42
Localisation : France

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : août 2004
Messages : 3 204
Points : 5 255
Points : 5 255
Salut,

Pour le formulaire comme tu le dit c'est limité à 3 couleurs (4 avec le blanc)

Par contre, pour l'état c'est possible, il faut agir sur l'évènement format ou print de la section détail et mettre à jour la couleur de fond des zones de texte.

Il y a un exemple en pièce jointe (Divers applications) sur ce tuto.
l'application se nomme "PlanningGardes v2"


Elle permet de définir les couleurs pour chaque code.

(Regarder le code dans l'état "R_Planning")

Elle réponds à divers demandes sur le forum Access

En très gros dans ton cas ce serait sur l'évènement print de la section détail de l'état (ou j désigne le numéro du jour du mois et Jour1..31 désigne les zones de texte):

Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
...
 
   If Me("Jour" & j).Value = "G" or Me("Jour" & j).Value = "J" or Me("Jour" & j).Value = "N" Then
 
      Me("Jour" & j).BackColor = vbyellow
 
   elseif If Me("Jour" & j).Value = "DG" or Me("Jour" & j).Value = "DJ" or Me("Jour" & j).Value = "DN" Then
 
      Me("Jour" & j).BackColor = vborange ' si ça existe
 
   elseif...
Bonne continuation,
__________________
Merci de ne pas poster sur mon profil pour des problèmes techniques. Pour celà vous pouvez utiliser le forum ou m'envoyer un mp.

Bon développement !


Mes tutoriels et contributions sur ma page perso:
Ma page personnelle
User est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/12/2010, 21h03   #6
Membre du Club
 
hugues dupont
Pompier
Inscription : janvier 2010
Messages : 170
Détails du profil
Informations personnelles :
Nom : hugues dupont
Localisation : France

Informations professionnelles :
Activité : Pompier

Informations forums :
Inscription : janvier 2010
Messages : 170
Points : 44
Points : 44
heu petit probleme voici mon code
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Dim ND As Integer, j As Integer
' Nombre de jours du mois.
ND = DaysInMonth(Forms!F_Planning!Mois, Forms!F_Planning!An)
For j = 1 To ND
 
   If Me("Jour" & j).Value = "G" Or Me("Jour" & j).Value = "J" Or Me("Jour" & j).Value = "N" Then
 
      Me("Jour" & j).BackColor = vbYellow
     ElseIf Me("Jour" & j).Value = "DG" Or Me("Jour" & j).Value = "DJ" Or Me("Jour" & j).Value = "DN" Then
 
      Me("Jour" & j).BackColor = vbRed
 End If
 
DateJ = DateJ + 1 ' Jour suivant.
Next j
voici le resultat
Pièce jointe 70688
hugodu28 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/12/2010, 21h23   #7
Rédacteur/Modérateur
 
Avatar de User
 
Homme Denis
Développeur informatique
Inscription : août 2004
Messages : 3 204
Détails du profil
Informations personnelles :
Nom : Homme Denis
Âge : 42
Localisation : France

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : août 2004
Messages : 3 204
Points : 5 255
Points : 5 255
Re,

Comme je te l'ai dit il faut agir sur l'évènemen print (sur impression) de la section détail de ton état R_Planning et ne pas toucher à la procédure MajReport:

Code :
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
Private Sub Détail_Print(Cancel As Integer, PrintCount As Integer)
Dim j As Integer, Color As Long, DateJ As Date
 
DateJ = DateSerial(Forms!F_Planning!An, Forms!F_Planning!Mois, 1)
 
For j = 1 To 31
 
     If Me("Jour" & j).Value = "G" Or Me("Jour" & j).Value = "J" Or Me("Jour" & j).Value = "N" Then
 
        Me("Jour" & j).BackColor = vbYellow
 
     ElseIf Me("Jour" & j).Value = "DG" Or Me("Jour" & j).Value = "DJ" Or Me("Jour" & j).Value = "DN" Then
 
        Me("Jour" & j).BackColor = vbRed
 
     Else
 
      If EstWeekEnd(DateJ) Or EstFerie(DateJ) Then
 
         Me("Jour" & j).BackColor = 13428479
 
      ElseIf EstConge(DateJ) Then
 
         Me("Jour" & j).BackColor = 12706047
 
      Else
 
         Me("Jour" & j).BackColor = vbWhite
 
      End If
 
   End If
 
DateJ = DateJ + 1
 
Next j
 
End Sub
A+
__________________
Merci de ne pas poster sur mon profil pour des problèmes techniques. Pour celà vous pouvez utiliser le forum ou m'envoyer un mp.

Bon développement !


Mes tutoriels et contributions sur ma page perso:
Ma page personnelle
User est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 23/12/2010, 14h32   #8
Membre du Club
 
hugues dupont
Pompier
Inscription : janvier 2010
Messages : 170
Détails du profil
Informations personnelles :
Nom : hugues dupont
Localisation : France

Informations professionnelles :
Activité : Pompier

Informations forums :
Inscription : janvier 2010
Messages : 170
Points : 44
Points : 44
est il possible d'obtenir le même resultat sur le formulaire?

voici le code du formulaire, où dois je placer le code conditionnel pour la mise en forme?

Code :
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
Dim DateJ As Date
 
DateJ = DateSerial(Forms!F_Planning!An, Forms!F_Planning!Mois, j)
 
DoCmd.OpenForm "F_Saisie", , , "[Matricule]=" & Mat & " and [DateJ]=" & FDateUs(DateJ)
 
Forms!F_Saisie!Matricule.Value = Mat
Forms!F_Saisie!Jour.Value = DateJ
 
 
      If EstWeekEnd(DateJ) Or EstFerie(DateJ) Then
 
         Me("Jour" & j).BackColor = 13428479
 
      ElseIf EstConge(DateJ) Then
 
         Me("Jour" & j).BackColor = 12706047
 
      Else
 
         Me("Jour" & j).BackColor = vbWhite
 
      End If
 
   End If
 
 
End Sub
 
Private Sub Jour1_DblClick(Cancel As Integer)
 
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 1
   End If
 
End Sub
 
Private Sub Jour10_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 10
   End If
 
End Sub
 
Private Sub Jour11_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 11
   End If
 
End Sub
 
Private Sub Jour12_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 12
   End If
 
End Sub
 
Private Sub Jour13_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 13
   End If
 
End Sub
 
Private Sub Jour14_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 14
   End If
 
End Sub
 
Private Sub Jour15_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 15
   End If
 
End Sub
 
 
Private Sub Jour16_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 16
   End If
 
End Sub
 
Private Sub Jour17_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 17
   End If
 
End Sub
 
Private Sub Jour18_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 18
   End If
 
End Sub
 
Private Sub Jour19_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 19
   End If
 
End Sub
 
Private Sub Jour2_DblClick(Cancel As Integer)
 
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 2
   End If
 
End Sub
 
Private Sub Jour20_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 20
   End If
End Sub
 
Private Sub Jour21_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 21
   End If
 
End Sub
 
Private Sub Jour22_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 22
   End If
 
End Sub
 
Private Sub Jour23_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 23
   End If
 
End Sub
 
Private Sub Jour24_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 24
   End If
 
End Sub
 
Private Sub Jour25_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 25
   End If
 
End Sub
 
Private Sub Jour26_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 26
   End If
 
End Sub
 
Private Sub Jour27_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 27
   End If
 
End Sub
 
Private Sub Jour28_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 28
   End If
 
End Sub
 
Private Sub Jour29_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 29
   End If
 
End Sub
 
Private Sub Jour3_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 3
   End If
 
End Sub
 
Private Sub Jour30_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 30
   End If
 
End Sub
 
Private Sub Jour31_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 31
   End If
 
End Sub
 
Private Sub Jour4_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 4
   End If
 
End Sub
 
Private Sub Jour5_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 5
   End If
 
End Sub
 
Private Sub Jour6_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 6
   End If
 
End Sub
 
Private Sub Jour7_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 7
   End If
 
End Sub
 
Private Sub Jour8_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 8
   End If
 
End Sub
 
Private Sub Jour9_DblClick(Cancel As Integer)
   If Not IsNull(Me!Matricule) And (Me!Matricule <> "") Then
      OuvrirFormSaisie CLng(Me!Matricule), 9
   End If
 
End Sub
 
Private Sub Prenom_DblClick(Cancel As Integer)
 
End Sub
 
Private Sub Matricule_DblClick(Cancel As Integer)
DoCmd.OpenForm "F_ConvocationAgent"
 
Forms!F_ConvocationAgent!Matricule = Me.Matricule
End Sub
 
Private Sub Nom_DblClick(Cancel As Integer)
DoCmd.OpenForm "F_ConvocationAgent"
 
Forms!F_ConvocationAgent!Matricule = Me.Matricule
 
End Sub
Bonnes fêtes de fin d'année à tous.
hugodu28 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/12/2010, 16h45   #9
Rédacteur/Modérateur
 
Avatar de User
 
Homme Denis
Développeur informatique
Inscription : août 2004
Messages : 3 204
Détails du profil
Informations personnelles :
Nom : Homme Denis
Âge : 42
Localisation : France

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : août 2004
Messages : 3 204
Points : 5 255
Points : 5 255
Salut,

Non ce n'est pas possible d'appliquer ce type de code sur un formulaire

Le type de code que je t'ai donné ne peut-être appliqué que sur print ou sur format d'1 état.

Ce que tu dois comprendre c'est que en mode continu quand tu définis une couleur de fond pour une zone de texte, cette couleur se répétera sur ce contrôle pour toutes les lignes

En mode continue ou feuille de données d'un formulaire on ne peut utiliser que la mise en forme conditionnelle qui n'autorise malheureusement que 3 conditions (3 couleurs).

Il faut disposer d'Access 2010 pour avoir plus de conditions dans la mfc et obtenir ainsi le même résultat que pour 1 état.

Tu n'es pas le premier à regretter une telle injustice

Pourquoi avoir attendu 2010 pour autoriser plus de conditions, j'avoue ne pas trop saisir...
__________________
Merci de ne pas poster sur mon profil pour des problèmes techniques. Pour celà vous pouvez utiliser le forum ou m'envoyer un mp.

Bon développement !


Mes tutoriels et contributions sur ma page perso:
Ma page personnelle
User est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/01/2011, 19h24   #10
Membre éclairé
 
Homme Pierre-Jean
Développeur informatique
Inscription : février 2010
Messages : 306
Détails du profil
Informations personnelles :
Nom : Homme Pierre-Jean
Âge : 31
Localisation : France

Informations professionnelles :
Activité : Développeur informatique
Secteur : Industrie

Informations forums :
Inscription : février 2010
Messages : 306
Points : 330
Points : 330
Envoyer un message via MSN à paidge
Lis ce tuto

J'ai réussi à faire une mise en forme conditionnelle sur 5 critères avec !
paidge est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/01/2011, 20h33   #11
Membre du Club
 
hugues dupont
Pompier
Inscription : janvier 2010
Messages : 170
Détails du profil
Informations personnelles :
Nom : hugues dupont
Localisation : France

Informations professionnelles :
Activité : Pompier

Informations forums :
Inscription : janvier 2010
Messages : 170
Points : 44
Points : 44
ok c'est pas la fin des haricots mais la nouvelle année alors on continu de sourir.
Merci quand même.
Bonne année à tous.
hugodu28 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 05h13.


 
 
 
 
Partenaires

Hébergement Web