Article ID: 286126 - View products that this article applies to.
This article was previously published under Q286126
Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access database (.mdb).
For a Microsoft Access 2000 version of this article, see 209157
When you open Microsoft Access and a form through Automation and set focus to the form's custom menu bar, you receive the following Microsoft Visual Basic error message:
Run-time error '-2147467259 (80004005)':
Method 'SetFocus' of object 'CommandBarPopup' failed
SetFocus fails because the control (in this case the menu bar) is not visible in the user interface at the time that the Automation code is executing.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this behavior, use either of the following methods.
Method 1: Trap for the ErrorEnter a function similar to the following:
Method 2: Insert a Time DelaySet focus by using code behind the form instead of the Automation code. For example, set the form's TimerInterval to 1000 (the value assigned may vary), and then add the following code to the form:
The run-time error that is mentioned in the "Symptoms" section occurs only when you use Automation. The occurrence varies based on whether or not Access is idle after the form opens, but before the Automation code attempts to set focus to a control. Variations in CPU speeds, program timing, and operating systems may cause this behavior to occur on some computers, but not others.
Steps to Reproduce the Behavior