Results 1 to 8 of 8
  1. #1
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108

    Event after hovering over a button

    Good morning,


    I was wanting to create an event to happen if a mouse is hovered over a button.
    I want it so another button appears but will go away if I mouse back off the original button.

    this is my code so far:
    Code:
    Private Sub Command26_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.cmdMagic.Visible = True
    End Sub
    and for the default value
    Code:
    Private Sub Default_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.cmdMagic.Visible = False
    End Sub
    It doesn't work right because I have to set the default value of the magic button visible to false. When I mouse over the command26 button cmdMagic appears but it wont go away after I mouse back off.
    Any idea?
    Thank you

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Maybe this????

    Your code...
    Code:
    Private Sub Command26_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Me.cmdMagic.Visible = True
    End Sub
    Then use the click event of the "magic" button to move the focus to another control and hide the button:
    Code:
    Private Sub cmdMagic_Click()
       'cannot set the visible property of a control if it has the focus
       'so set the focus to another control
        Me.Text2.SetFocus    ' <--  some other control - any control
        'now hide the button
        Me.cmdMagic.Visible = False
    End Sub

  3. #3
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    or in the form detail (or whichever section your button is in) put code in the mousemove event to hide the button

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Ajax has given you the definitive answer...but what good does it do to have cmdMagic appear, when hovering over Command26, only to disappear when backing off of it? You can never use cmdMagic because you have to move off of Command26 in order to attempt to click on cmdMagic, but cmdMagic won't be there to be clicked!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Missinglinq View Post
    ...what good does it do to have cmdMagic appear, when hovering over Command26, only to disappear when backing off of it?...
    Maybe it is a government contract.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Not even sure that that's 'good enough for government work!'
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Missinglinq View Post
    ...but what good does it do to have cmdMagic appear, when hovering over Command26, only to disappear when backing off of it? You can never use cmdMagic because you have to move off of Command26 in order to attempt to click on cmdMagic, but cmdMagic won't be there to be clicked!
    Hovering over Command26 causes cmdMagic to be displayed, but there isn't any code to re-hide cmdMagic. In the code I presented, clicking cmdMagic would set the focus to another control, then set cmdMagic to be not visible.

    Would this not work?

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The point is...the OP wants to make cmdMagic, a Command Button, Visible, when hovering over Command26, only to make it not Visible, when you stop hovering over Command26! You would have to stop hovering over Command26, in order to move to cmdMagic and click on it, but it would then have disappeared!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. how to trigger a button event at same form
    By newaccess in forum Forms
    Replies: 10
    Last Post: 03-01-2013, 10:02 AM
  2. Trigger event with button click
    By AMAS in forum Forms
    Replies: 8
    Last Post: 06-07-2012, 09:42 AM
  3. Replies: 5
    Last Post: 08-29-2011, 04:06 PM
  4. Command button click event
    By R_jang in forum Programming
    Replies: 10
    Last Post: 10-29-2010, 10:13 PM
  5. On Click Event For Button On Form
    By Desstro in forum Forms
    Replies: 3
    Last Post: 08-09-2010, 02:36 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