Apply Conditional Formatting to a subform by Check Box on Main Form
Hi,
I would like to apply Conditional Formatting to a SubForm if a CheckBox on my MainForm is selected.
My SubForm resides on a tabbed sheet on my MainForm (although according to Labans, this makes no difference to its referencing).
The code I am now using runs without error (!) but does not invoke the Conditional Formatting.
Does anyone know why this does not work?
DubaiDave
Here it is:
Hi,
I would like to apply Conditional Formatting to a SubForm if a CheckBox on my MainForm is selected.
My SubForm resides on a tabbed sheet on my MainForm (although according to Labans, this makes no difference to its referencing).
The code I am now using runs without error (!) but does not invoke the Conditional Formatting.
Does anyone know why this does not work?
DubaiDave
Here it is:
Code:
Public Sub subConditionalFormat()
' [URL="http://msdn.microsoft.com/en-us/library/aa139965(office.10).aspx"]http://msdn.microsoft.com/en-us/libr...ffice.10).aspx[/URL]
Dim objFrc As FormatCondition
Dim lngRed As Long
Dim lngGreen As Long
Dim lngWhite As Long
Dim lngBlack As Long
Dim cntrl As Control
' Set up foreground colors.
lngRed = RGB(255, 0, 0)
lngWhite = RGB(255, 255, 255)
lngBlack = RGB(0, 0, 0)
lngGreen = RGB(0, 255, 0)
' Remove any existing format conditions.
Me![fmSafetyNoticeReportContForm].Form![ClosedStatus].FormatConditions.Delete
' Create three format objects and add them to the FormatConditions
' collection.
Set objFrc = Me![fmSafetyNoticeReportContForm].Form![ClosedStatus].FormatConditions.Add(acFieldValue, acEqual, "Closed")
Set objFrc = Me![fmSafetyNoticeReportContForm].Form![ClosedStatus].FormatConditions.Add(acFieldValue, acEqual, "Open")
Set objFrc = Me![fmSafetyNoticeReportContForm].Form![ClosedStatus].FormatConditions.Add(acFieldValue, acEqual, "NoStatus")
With Me![fmSafetyNoticeReportContForm].Form![ClosedStatus].FormatConditions(0)
.Enabled = True
.BackColor = lngWhite
.ForeColor = lngRed
End With
With Me![fmSafetyNoticeReportContForm].Form![ClosedStatus].FormatConditions(1)
.Enabled = True
.BackColor = lngWhite
.ForeColor = lngRed
End With
With Me![fmSafetyNoticeReportContForm].Form![ClosedStatus].FormatConditions(2)
.Enabled = True
.BackColor = lngWhite
.ForeColor = lngRed
End With
Set objFrc = Nothing
Last edited: