Auto close form when mouse moved

A

avnguyen

Hello,

I have a form which has a reference button in it. When I want to check for
reference, I move my mouse over the button, the reference form opens(got it
working). Question is how do I code it to close when I move the my mouse away
from the button? thx in advance.
 
M

Marshall Barton

avnguyen said:
I have a form which has a reference button in it. When I want to check for
reference, I move my mouse over the button, the reference form opens(got it
working). Question is how do I code it to close when I move the my mouse away
from the button?


Difficult to get this reliably. The easiest is to use the
form's section MouseMove event to close the form.

BUT, if there are other controls "close" to the button a
rapid mouse movement may not fire for the form and you need
to use MouseMove on those controls too. In this situation,
it's easiest to create a Function procedure to check if the
form is open and close it if it is. Then set the section's
and those "near by" controls MouseMove event to call the
function. It might be a good idea to use a function even if
there are no "near by" controls

Function CloseRef()
If CurrentProject.AllForms("Name of form").IsLoaded Then
DoCmd.Close acForm, "Name of form", acSaveNo
End If
End Function
 
D

Dale Fye

Well, there are several ways to do this.

1. Enable the Close button on the Reference forms properties sheet, and
click that.

2. Add a command button on the Reference form and use it to close the
Reference form.

3. Add some code to the MouseMove event of your main forms detail section.
In that event, test to see whether the Reference form is loaded. Is so,
close it. The problem with this is that it will do this any time you use the
mouse to navigate around the form, which can be resource intensive. If you
want to do this, then use the following to test for the Reference form being
open:

currentproject.Allforms("FormName").isloaded

Replace "FormName" with the actual name of your Reference form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top