View Full Version : Catch 22


aziz rasul
12-14-2000, 05:25 AM
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.

rjohnstone1
12-14-2000, 09:14 AM
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

aziz rasul
12-15-2000, 03:03 AM
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.

simongallop
12-15-2000, 03:34 AM
At the beginning of your OnClick event try this line of code. It seems to work

Me.Command1.OnMouseMove = ""

aziz rasul
12-15-2000, 06:34 AM
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.

simongallop
12-15-2000, 07:01 AM
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]"

aziz rasul
12-18-2000, 07:36 AM
Thanks for that Simon. I'm not particularly good at VBA. Hence I didn't fully appreciate how to continue. Your suggestion worked. Whopee!