H
Harmannus
Hallo,
I got the below code for hightlighting a record. Works fine but in stead of
putting it on every form i would like to put in a module and call it from
every form.
How can i extend the below code to achieve this? Tried some coding but I get
an error on the me.controls line. Any suggestions? Is it also possible to
extend the code to work with a combo box? Thanx for any tips.
if the control gets the focus changes the color to yellow
Function CtlGotFocus(ctl As Control)
On Error Resume Next
Set ctl = Screen.ActiveControl
ctl.BackColor = RGB(255, 255, 0)
End Function
' if the control loses the focus changes the color to back to white
Function CtlLostFocus(ctl As Control)
On Error Resume Next
Set ctl = Screen.ActiveControl
ctl.BackColor = RGB(255, 255, 255)
End Function
Function setHighlight(ctl As Control)
On Error Resume Next
For Each ctl In Me.Controls
If ctl.ControlType = 109 Then
ctl.OnGotFocus = "=CtlGotFocus"
ctl.OnLostFocus = "=CtlLostFocus"
End If
Next
End Function
Form_open
call setHighlight
Regards,
Harmannus
I got the below code for hightlighting a record. Works fine but in stead of
putting it on every form i would like to put in a module and call it from
every form.
How can i extend the below code to achieve this? Tried some coding but I get
an error on the me.controls line. Any suggestions? Is it also possible to
extend the code to work with a combo box? Thanx for any tips.
if the control gets the focus changes the color to yellow
Function CtlGotFocus(ctl As Control)
On Error Resume Next
Set ctl = Screen.ActiveControl
ctl.BackColor = RGB(255, 255, 0)
End Function
' if the control loses the focus changes the color to back to white
Function CtlLostFocus(ctl As Control)
On Error Resume Next
Set ctl = Screen.ActiveControl
ctl.BackColor = RGB(255, 255, 255)
End Function
Function setHighlight(ctl As Control)
On Error Resume Next
For Each ctl In Me.Controls
If ctl.ControlType = 109 Then
ctl.OnGotFocus = "=CtlGotFocus"
ctl.OnLostFocus = "=CtlLostFocus"
End If
Next
End Function
Form_open
call setHighlight
Regards,
Harmannus