I am trying to use the code from the AccessWeb internet site ( to change the backcolor of a control on any form when the mouse is moved over it.
The original code is by Dev Ashish.
I am using the following code in a module
I am then calling fSetBackColor from the OnMouseMove event of the control (i.e. =fSetBackColor([Forms]![myFrm]![myTXT])
I am calling fRemoveBackcolor from the onMouseMove of the detail section which surrounds the controls (i.e. =fRemoveBackcolor()
The backcolor changes when I move onto the control but does not return to how it was when I move off the control (so a problem with the fRemoveBackcolor function or how I am calling it or even with the variable 'mstPrevControl'). The original code works fine but you have to repeat the code on each form. I am trying to modularise the code so that is can be used on any form.
Thanks in advance for any help.
Jonathan
The original code is by Dev Ashish.
I am using the following code in a module
Code:
Global mstPrevControl As Control
Function fSetBackColor(ctlControlName As Control)
' Code Courtesy of
' Dev Ashish
On Error Resume Next
Call fRemoveBackcolor
mstPrevControl = ctlControlName
With stControlName
.BackColor = 16744576
End With
End Function
Function fRemoveBackcolor()
' Code Courtesy of
' Dev Ashish
On Error Resume Next
With mstPrevControl
.BackColor = 12632256
End With
End Function
I am then calling fSetBackColor from the OnMouseMove event of the control (i.e. =fSetBackColor([Forms]![myFrm]![myTXT])
I am calling fRemoveBackcolor from the onMouseMove of the detail section which surrounds the controls (i.e. =fRemoveBackcolor()
The backcolor changes when I move onto the control but does not return to how it was when I move off the control (so a problem with the fRemoveBackcolor function or how I am calling it or even with the variable 'mstPrevControl'). The original code works fine but you have to repeat the code on each form. I am trying to modularise the code so that is can be used on any form.
Thanks in advance for any help.
Jonathan