Function setEvent(ByRef frm As Form) As Integer
On Error Resume Next
Dim p As Property
For Each p In frm.Properties
If Left(p.Name, 2) = "On" _
Or Left(p.Name, 5) = "After" _
Or Left(p.Name, 6) = "Before" Then
p.Value = "=msgbox('" & p.Name & "')"
End If
Next p
End Function