Microsoft KB Archive/213864

= ACC2000: Event Procedure Property of a Form Is Not Set If You Create Event Procedure in Form View =

Article ID: 213864

Article Last Modified on 7/16/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q213864



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

Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
If you create an event procedure for a Microsoft Access form in Form view, the event procedure will work as long as the form remains in Form view. However, when you switch the form to Design view and then back to Form view, the event procedure no longer works.



RESOLUTION
Create event procedures only in Design view.



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



MORE INFORMATION
When you create a new event procedure in Design view of a form, the property for that event procedure is set automatically, and the procedure works when you switch to Form view. If the form is in Form view when you create the new procedure, the procedure works as long as the form remains in Form view. However, when you switch to Design view, you find that the property for that event procedure is not set. When you then switch back to Form view, the procedure no longer works.

Steps to Reproduce the Behavior
 Create a new form in any Microsoft Access database. In Design View of the form, right-click the detail section, click Build Event, click Code Builder, and then click OK.  Type the following code: Private Sub Detail_Click MsgBox "Single Click" End Sub  Press ALT+TAB to switch back to the Access form. On the View menu, click Form View, and then click anywhere in the detail section of the form. Note that the message box appears.</li> Leave the form open in Form view, and then press ALT+TAB to switch back to the Visual Basic Editor.</li> Click the arrow in the Procedure box, and then click DblClick.</li>  Type the following code: Private Sub Detail_DblClick(Cancel As Integer) MsgBox "Double Click" End Sub </li>  Delete the following code that you typed in step 3: Private Sub Detail_Click MsgBox "Single Click" End Sub </li> Press ALT+TAB to switch back to the Access form, and then double-click the form. Note that the message box appears.</li> On the View menu, click Design View, and then on the View menu again, click Form View.</li> Double-click the form. Note that the message box no longer appears.</li></ol>

In Design view of the form, note that the OnDblClick event property is not set.

<div class="references_section">