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



The information in this article applies to:

  • Microsoft Access 2000

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

  1. Create a new form in any Microsoft Access database.
  2. In Design View of the form, right-click the detail section, click Build Event, click Code Builder, and then click OK.
  3. Type the following code:
    Private Sub Detail_Click()
        MsgBox "Single Click"
    End Sub
    					
  4. Press ALT+TAB to switch back to the Access form.
  5. On the View menu, click Form View, and then click anywhere in the detail section of the form. Note that the message box appears.
  6. Leave the form open in Form view, and then press ALT+TAB to switch back to the Visual Basic Editor.
  7. Click the arrow in the Procedure box, and then click DblClick.
  8. Type the following code:
    Private Sub Detail_DblClick(Cancel As Integer)
        MsgBox "Double Click"
    End Sub
    					
  9. Delete the following code that you typed in step 3:
    Private Sub Detail_Click()
        MsgBox "Single Click"
    End Sub
    					
  10. Press ALT+TAB to switch back to the Access form, and then double-click the form. Note that the message box appears.
  11. On the View menu, click Design View, and then on the View menu again, click Form View.
  12. Double-click the form. Note that the message box no longer appears.
In Design view of the form, note that the OnDblClick event property is not set.

REFERENCES

worked once won't run again stops working

Modification Type:MinorLast Reviewed:7/16/2004
Keywords:KB213864