Catch 22

aziz rasul

Active member
Local time
Today, 16:27
Joined
Jun 26, 2000
Messages
1,935
I have a series of buttons on a form. Let's call them Command1, Command2 & Command3.

Under each of the command buttons, under the "On Mouse Move" event, I have: -

DoCmd.GoToControl "Command1"
DoCmd.GoToControl "Command2"
DoCmd.GoToControl "Command3"

When the mouse moves over a particular command button, it gives the impression that the command buttons have the focus.

I have an event procedure behind Command1 which runs a serious of queries. If a user moves the mouse over the command buttons, when the event procedure is running, it comes up with a run-time error 2486. The error message is "You can't carry out this action at the present time".

I temporarily solved the problem by making the Enabled property of command buttons, "Command2" & "Command3" equal to False and reset them to True at the end of the procedure.

However I still have the problem that a user may still move the mouse over "Command1" while the procedure is running. Any ideas how I can resolve this.

I have posted this topic in the Modules & VBA section as well.
 
The only thing that i could come up with
is DoCmd.hourglass in your subroutines
or use some sort of timer to wait until
your queries stop.

Ryan Johnstone
 
Thanks Ryan.

I will look into the Hourglass action\method. I've never used it. Looking into Help, I also found the Echo action\method.
 
At the beginning of your OnClick event try this line of code. It seems to work

Me.Command1.OnMouseMove = ""
 
It works when you press Command1 and while it carries out the event behind the button. However it disables the OnMouseMove events AFTERWARDS as well!

Is there some code that I can add after the procedure to reset the GoToControl DoCmd method.
 
Sorry thought that you could see what is happening. If you look at the properties for the buttons you will notice that for the Mouse Move event it say [Event Procedure]

The first piece of code is saying replace [Event Procedure] with "". So therefore to replace it you need the following code at the end of the proc being:

Me.Command1.OnMouseMove = "[Event Procedure]"
 
Thanks for that Simon. I'm not particularly good at VBA. Hence I didn't fully appreciate how to continue. Your suggestion worked. Whopee!
 

Users who are viewing this thread

Back
Top Bottom