ACC2002: Cannot Add Control While Code Is Running Behind Form (295228)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q295228
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you try to add a control to a form, you receive the following error message:
Microsoft Access can't add, rename, or delete the control(s) you requested.

CAUSE

If code in the module of a form continues to run after the form has been closed, you may not be able to add new objects to the form.

RESOLUTION

Close and then reopen the database. Change the code so that it does not continue to run after the form is closed.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb.
  2. Open the Customers form in Design view.
  3. Add a command button to the form. Cancel the Command Button Wizard if it starts.
  4. Type or paste the following code in the Click event of the command button.
    Private Sub Command0_Click()
         While True
              DoEvents
         Wend
    End Sub
    					
  5. Save and then close the form.
  6. Open the Customers form in Form view, and then click the command button. Close the form.
  7. Open the form again in Design view, and then try to add any control.
Note that you receive the error message that is mentioned in the "Symptoms" section of this article.

Modification Type:MajorLast Reviewed:11/5/2003
Keywords:kbbug kberrmsg kbpending KB295228