Error 2046 with DoCmd.RunCommand acCmdFreezeColumn
Posted on 2007-03-20
I am bringing up a subform as a datasheet inside a form. I would like to freeze the first three columns. I do this using code like this in the Form_Open event:
This used to work. However, I added a GotFocus event to Col3 and now after executing that code, the next time it tries to execute the DoCmd statement I get Error 2046 "command isn't available".
I have tried a number of things to try and get this to work:
1) Trapped and ignored the error: The problem is that the columns don't come up in the right order anymore.
2) Set a boolean value so that I could skip all of the code in the GotFocus event during the Open_Form event: This doesn't work. It seems that just going to the event even if there is no code there causes the problem.
3) Added a pause: even with pause as long as 10 seconds this didn't work.
Is there a solution? The only things I can think of are:
1) Is there a way to deactivate an event completely and then reactivate it?
2) Is there a way to create the event programatically? Then I could create it after I execute the other code.