Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MouseMove help with modularising code

Status
Not open for further replies.

UHNSTrust

Technical User
Dec 2, 2003
262
GB
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
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
 
What is stControlName ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry,

I had not noticed this on my post it should be ctlControlName. I had tried to put my code into a more readable way.

The problem remains the same as it is right in my database code.

Sorry for the typing mistake.

Jonathan
 
You try to replace this:
mstPrevControl = ctlControlName
By this:
Set mstPrevControl = ctlControlName

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH I spoke too soon.

This does work fine for textbox controls but I have found that this stops me from dropping down comboboxes.

Does anybody have any ideas why this is happening? Could it be that this event is firing when the mouse is clicked?

Jonathan
 
That event will constantly fire whenever the mousepointer is over the control.

Hope this helps

HarleyQuinn
---------------------------------
Help us to help you,
read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top