Results 1 to 4 of 4
  1. #1
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71

    Thumbs up Mousemove event determine control name


    I have a module tied to a mousemove event and I'm trying to get the name of the control the mouse is over. I realize that I can't use screen.activecontrol.name since the control may not have the focus. But there's got to be some way for me to tickle Access into given me the name of the control that's firing the mousemove event.

    I'm looking for the control name in order to make a generic module that I can use on multiple controls. The control name is being used in a DLookup function to find a value in a table.

    Any ideas of where to begin?

    DD

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Can you post the code you have for the mousemove?

  3. #3
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71
    Quote Originally Posted by orange View Post
    Can you post the code you have for the mousemove?
    Here's what I've worked out so far - I actually got the control name to come across using this.
    The script I'm using is:
    Code:
    Public Function ImagePopup(ByRef Ctrl As control)
    Dim ControlNamestr As String
    Dim ControlImagestr As String
    
    
    If CurrentProject.AllForms("picturetesting").IsLoaded Then
    Else
    ControlNamestr = Left(Ctrl.Name, Len(Ctrl.Name) - 7)
    ControlImagestr = DLookup("ImageSubf", "ControlPictures", "ControlName = '" & ControlNamestr & "'")
    
    DoCmd.OpenForm "picturetesting"
    Forms!picturetesting!PictureSubf.SourceObject = ControlImagestr
    Forms!picturetesting.Caption = ControlNamestr
    
    End If
    The function is checking if my popup form is already open to eliminate the flicker you'd get if it was constantly trying to open the form/subform. It it's not open then it opens it and sets the SourceObject equal to the value it gets in the DLookup. It also uses the control name to set the popup window's caption so that its titled correctly.

    I put the function name with the control name in parenthesis directly into the On Mouse Move option box like this =ImagePopup([checktwodisplay]) - I can't take credit for that, I found it online. This is then set in the function as CTRL. In the script CTRL.Name is the name of the control, which I can then manipulate to knock off the suffix and use to look up a value in the table.

    I haven't found anything that lets me do this via straight vba, which is what I'd really like. I'd like to be able to just put ImagePopup into the vba without having to enter the control name. My reasoning for that is to eliminate the need to change script should a control name change. I'd only have to change the control name and the script would take it in stride. If I have to leave it this way then so be it, but I'm hoping that someone can point me in a VBA direction.

    DD

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    I was wondering, and haven't found any vba to support this, whether or not you can use Mousemove with the form itself. Then check for each control on the form and get its Name and Position Top Left, width and height. Then check to see if the mouse cursor is within the bounds of any control. If it is, then ??somehow?? show the control name. Debug.Print wouldn't be too helpful, nor MsgBox. Just some thinking.

    I have some code that works with a control - a button with a caption- if you move outside the bounds of the control, the caption disappears. I can get it to debug.print the control name. If you move the cursor back within the bounds of the control, its caption reappears.

    When you look at a form with Access, you'll notice the cursor changes when you go to a textbox for example. So, it is aware of the control boundary.

    Just some thoughts that may help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-21-2015, 07:08 PM
  2. Replies: 11
    Last Post: 11-13-2014, 08:52 PM
  3. Replies: 4
    Last Post: 02-14-2013, 10:06 AM
  4. tab control - firing a page on-click event
    By Chuck55 in forum Programming
    Replies: 7
    Last Post: 05-01-2012, 09:57 AM
  5. User focus control in AfterUpdate event
    By nosliwmada@gmailcom in forum Programming
    Replies: 3
    Last Post: 12-20-2010, 12:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums