Ich habe ein Testformular mit einem einzigen Kombinationsfeld, in dem ich eine bedingte Formatierung basierend auf der Option im Feld ausgewählt habe. Das Kombinationsfeld hat das Tag "Conditional".Kann bedingte Formatierung in Access 2013 nicht löschen
Um die bedingte Formatierung zu ändern, habe ich ein Sub-Formular geöffnet. In Zukunft wird dies auf viele Kombinationsfelder mit dem Tag "Conditional" angewendet.
Private Sub ApplyCondFormatting()
Dim objFrc As FormatCondition
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "Conditional" Then
With ctl
'Remove format conditions
.FormatConditions.Delete
MsgBox ("Test")
'Apply new format conditions
Set objFrc = .FormatConditions.Add(acExpression, acEqual, "[Value] = Correct")
Set objFrc = .FormatConditions.Add(acFieldValue, acEqual, "[Value] = Incorrect")
'Specify the formating conditions
.FormatConditions(0).BackColor = RGB(0, 255, 0)
.FormatConditions(0).Enabled = True
.FormatConditions(1).BackColor = RGB(255, 0, 0)
.FormatConditions(1).Enabled = True
End With
End If
Next ctl
Set objFrc = Nothing
End Sub
Die MsgBox erscheint, so das Makro ist ordnungsgemäß ausgeführt, aber es wird nicht gelöscht, die alte oder die neue Formatierung hinzuzufügen. Was vermisse ich?
Gibt es eine Möglichkeit, dies ohne Öffnung zu tun Designansicht? Mein Code wird ausgeführt, wenn der Benutzer eine Schaltfläche drückt. – jjjjjjjjjjj
@jjjjjjjjjj: Vielleicht müssen Sie Ihre Situation weiter erläutern (bitte bearbeiten Sie dazu Ihre Frage). Wenn Ihr Sub-Member auf jedem Form_Open ausgeführt wird, spielt es keine Rolle, ob die Änderung dauerhaft ist. Oder funktioniert Ihre '.FormatConditions.Delete'-Zeile überhaupt nicht, nicht einmal für die aktuelle Formularinstanz? – Andre
Es ist das letztere. Die Linie funktioniert überhaupt nicht. – jjjjjjjjjjj