Results 1 to 5 of 5
  1. #1
    robs23 is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2014
    Posts
    109

    Form_mouseMove - get it working even if cursor is upon textbox/label

    Hi Guys,

    Can I get Form_mouseMove or Detail_mouseMove event called even when cursor is upon textbox/label? I have at least 30 textboxes on my form and I want their borders to go red when cursor is upon them but i don't want to create >30 textbox_mousemove events.. With form_mousemove I can get current cursor position and check whether it matches position of any of the textboxes. Unfortunately, currently both Form_MouseMove and Detail_MouseMove won't trigger when the cursor is moving upon other object.. How can I get round it?

    Regards,


    Robert

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You could have one function and call it in the textbox event property. I have done this for a form full of buttons. Example:
    Code:
    Private Function HandleButtonClick(intBtn As Integer)
    'this procedure is called when a button is clicked
    'intBtn indicates which button was clicked
    Select Case intBtn
        Case 1
            DoCmd.OpenForm "AirportData"
        Case 2
            DoCmd.OpenReport "Fax", acViewPreview
        Case 3
            DoCmd.OpenReport "Summary", acViewPreview
        Case 4
            DoCmd.OpenReport "ContactList", acViewPreview
        Case 5
            UpdateFromPaver
        Case 6
            ExportAASP
        Case 7
            DoCmd.OpenReport "Imagery", acViewPreview
        Case 8
            DoCmd.OpenReport "Strength", acViewPreview, , , acDialog
        Case 9
            DoCmd.Quit acQuitSaveNone
    End Select
    End Function
    Then in the event property:
    =HandleButtonClick(1)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    don't want to create >30 textbox_mousemove events
    to work with June7's suggestion you would need to pass a value which references the control - e.g. =MseMove([Text1])

    then your function would be

    Code:
    public function mseMove(ctrl as control)
    
        ctrl.bordertype=1
    
    end function
    you can write a bit of vba code to populate the onevents

    for each ctrl in me.controls
    ctrl.onmousemove="=(mseMove([" & ctrl.name & "])"
    next ctrl

    also, just in case you are not aware - labels associated with a control do not have events. You need to disassociate them to get the events

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The function will probably need code that resets all textboxes back to neutral and then highlight the one of interest.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    agreed

    Code:
    public function mseMove(ctrl as control)
    dim ctl as control
    
    'no way of knowing which was the last control (if any), so reset all
    for each ctl in me.controls 
        ctl.bordertype=0
    ' could use if..else here but suspect process time would be increased
    next ctl
    
    ctrl.bordertype=1
    
    end function

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

Similar Threads

  1. Replies: 9
    Last Post: 09-02-2014, 10:56 AM
  2. Replies: 3
    Last Post: 06-02-2014, 07:33 AM
  3. textBox Value making label visible
    By barkly in forum Forms
    Replies: 5
    Last Post: 07-24-2013, 07:05 PM
  4. Replies: 10
    Last Post: 03-06-2012, 11:48 AM
  5. Textbox/label Visible
    By prawln in forum Programming
    Replies: 6
    Last Post: 05-20-2011, 01:57 PM

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