Graham,
That works - sort of!
I have a 'main' form that has a Sub Form control on it. The function i am
using highlights a text box label when the mouse moves over the text box, on
the form within the sub form.
The function looks like this and is called from the Sub Form:
Public Function Change_Control_Colour(ctl As Access.Control, frm As
Access.Form, Optional strInitial_Colour As String, Optional
strHighlight_Colour As String)
Dim ctl2 As Access.Control
' If strInitial_Colour or strHightlight_Colour = "" then change them to
the 'standard' colours.
If strInitial_Colour = "" Then strInitial_Colour = 128
If strHighlight_Colour = "" Then strHighlight_Colour = 16711680
' This function changes the fore colour of the passed ctl
With ctl
' Change the fore colour of the control
If ctl.ForeColor <> Val(strHighlight_Colour) Then .ForeColor =
Val(strHighlight_Colour)
End With
' Reset the colour for the rest of the COL controls.
For Each ctl2 In frm.Controls
If Right(ctl2.Name, 3) = "COL" And ctl2.Name <> ctl.Name _
And ctl2.ForeColor <> Val(strInitial_Colour) Then
ctl2.ForeColor = Val(strInitial_Colour)
End If
Next ctl2
Set ctl = Nothing
Set ctl2 = Nothing
Set frm = Nothing
End Function
The part where the colour of the other controls is set back to the initial
colour (For Each ctl2 in frm.Controls) doesnt work. I am guessing this is
because I need to reference the 'main' form as well (i.e.
frmMain!subForm!Textbox) Can this be done?
Thanks for the help,
Steve.