Hi
I have the following code on a continuous form which gives various formatting if the record is selected.
I would really like to add conditional formatting if the record is not selected so say an option where NoLongerCropped = True and an option where FertRecStatus = -1.
Is this possible and if so where do I put the code?
Thanks
I have the following code on a continuous form which gives various formatting if the record is selected.
I would really like to add conditional formatting if the record is not selected so say an option where NoLongerCropped = True and an option where FertRecStatus = -1.
Is this possible and if so where do I put the code?
Thanks
Code:
Private Sub Form_Current()
'varCondition must be numeric for this to work
Dim ctl As Control, strForm As String, varCondition As Variant
Dim fcs As FormatConditions, fc As FormatCondition
Dim lngColour As Long
Dim lngColour2 As Long
Dim Font As Long
On Error Resume Next
varCondition = Me!CroppingNumber
'This code overrides the conditional formatting appplied WHEN the records have focus using the Cropping Number
If Me!FertRecStatus = -1 Then
lngColour = vbWhite 'white background
lngColour2 = vbRed 'Red font
Font = True 'Font is bold
ElseIf Me!NoLongerCropped = True Then
lngColour = 12040119 'Gray background
lngColour2 = vbBlack 'Black Font
Font = False 'Font is normal
Else
lngColour = vbWhite 'white background
lngColour2 = vbBlack 'Black Font
Font = True 'Font is bold
End If
For Each ctl In Me.Controls
If ctl.Tag = "ConditionalFormat" Then
Set fcs = Me.Controls(ctl.Name).FormatConditions
fcs.Delete 'Deletes any other Conditional Formatting, limit is 3
Set fc = fcs.Add(acExpression, , "CroppingNumber=" & varCondition)
fc.BackColor = lngColour
fc.ForeColor = lngColour2
fc.FontBold = Font
End If
Next ctl
Dim ParentDocName As String
On Error Resume Next
ParentDocName = Me.Parent.Name
If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
End If