you cant disable a control while it has focus

awade

Registered User.
Local time
Tomorrow, 06:02
Joined
Apr 21, 2013
Messages
101
good morning,

I have a form that allows me to update entries in a table. When I select the line I need to update and hit the "edit" button I get a run time error '2164' You cant disable a control while it has the focus. when I debug the line in the code that is highlighted yellow is
Me.cmdEdit.Enabled = False.

I developed the database in access 2013, and now I am forced to run the database on a computer that has Access 2003. I have changed the database base to access 2000-2003.

Can anyone help me remove this Run time error.

Thanks in advance.
 
Just like the error message says really. Comment out that code line and it won't error there.
 
@vbaInet. thanks for the response.

As im very new to code, I am unsure on how to do this.

Can you please explain what I need to write in the code line.

Thanks.
 
At the beginning of the line of code write Rem or if you prefer like most people do

use ' instead

The other thing to do is to move the focus somewhere else. Move to a hidden control, Run your code then put the focus back to cmd.edit where it originally was.

Untested.
 
@RainLover. I have written Rem prior to Me.cmdEdit. Enabled = False
and it works a treat.

Thank you for your explanation.
 
@RainLover. I have written Rem prior to Me.cmdEdit. Enabled = False
and it works a treat.

Thank you for your explanation.

In future you can use an apostrophe instead of REM.

I only use REM when I want it to stand out. Both do the same thing.

If you are happy with the solution then please mark the thread with SOLVED. Go to the very first post and you will find a dropdown before the name of the Thread.
 

Users who are viewing this thread

Back
Top Bottom