Print Conditional Formatting

  • Thread starter Thread starter Gitche Gumee
  • Start date Start date
Sub snoopFormatConditions()

Set frm = Forms("frmTrailerDispatch")

For i = 0 To frm.Controls.Count - 1
Set ctl = frm.Controls(i)
With ctl
Debug.print
"--------------------------------------------------------------"
Debug.Print .Name, .ControlType
If .ControlType = acComboBox Or .ControlType = acTextBox Then
For j = 0 To .FormatConditions.Count - 1
Debug.Print .FormatConditions(j).Expression1
Debug.Print .FormatConditions(j).Expression2
Debug.Print .FormatConditions(j).Enabled
Debug.Print .FormatConditions(j).ForeColor
Debug.Print .FormatConditions(j).BackColor
Next j
End If
End With
Next i

Set frm = Nothing

End Sub

For the code to work, you'll need to have the form open as if you're
adding/editing records. There are several properties invovled as well such as
..Enabled, .BackColor, .ForeColor and I think two others. Check VBA Help under
FormatCondition Object for the specifics.
 
Thanks! That's just what I needed.

dch3 said:
Sub snoopFormatConditions()

Set frm = Forms("frmTrailerDispatch")

For i = 0 To frm.Controls.Count - 1
Set ctl = frm.Controls(i)
With ctl
Debug.print
"--------------------------------------------------------------"
Debug.Print .Name, .ControlType
If .ControlType = acComboBox Or .ControlType = acTextBox Then
For j = 0 To .FormatConditions.Count - 1
Debug.Print .FormatConditions(j).Expression1
Debug.Print .FormatConditions(j).Expression2
Debug.Print .FormatConditions(j).Enabled
Debug.Print .FormatConditions(j).ForeColor
Debug.Print .FormatConditions(j).BackColor
Next j
End If
End With
Next i

Set frm = Nothing

End Sub

For the code to work, you'll need to have the form open as if you're
adding/editing records. There are several properties invovled as well such as
.Enabled, .BackColor, .ForeColor and I think two others. Check VBA Help under
FormatCondition Object for the specifics.
 
You may want to keep it handy as I've had to snoop the controls & their
properties on multiple occasions. Just remove the For J Next Loop and replace
it with the property that your snooping such as .controlSource or .tag.
 
Back
Top