From: Mat on
In a class form I am doing the following.

Public Property Set Form(FrmIn As Access.Form)
Set frm = FrmIn
frm.OnGotFocus = "[Event Procedure]"
frm.BeforeUpdate = "[Event Procedure]"
End Property

Private Sub frm_BeforeUpdate(Cancel As Integer)
MsgBox "This code is running. :)"
End Sub

Private Sub frm_GotFocus()
MsgBox "This code isn't running. Why :("
End Sub

The event I create for before update is working for forms that use the
class but not for the gotfocus event. Is this to do with the fact that
the event is called beforeupdate in both places and called ongotfocus
and gotfocus?
From: Mat on
I should add that if I go to the form in design view and add the
"[Event Procedure]" text to the appropriate event the code runs for
the form class. I obviously prefer adding these links in code for
simplicity.
From: Mat on
Also I am using withevents in the class module:

Private WithEvents frm As Access.Form
From: Mat on
Actually the above works. The GotFocus event wasn't triggering when I
thought it should.
From: Krzysztof Naworyta on
Juzer Mat <matthew.kay(a)optusnet.com.au> napisal
| In a class form I am doing the following.
|
| Public Property Set Form(FrmIn As Access.Form)
| Set frm = FrmIn
| frm.OnGotFocus = "[Event Procedure]"
| frm.BeforeUpdate = "[Event Procedure]"
| End Property
|
| Private Sub frm_BeforeUpdate(Cancel As Integer)
| MsgBox "This code is running. :)"
| End Sub
|
| Private Sub frm_GotFocus()
| MsgBox "This code isn't running. Why :("
| End Sub
|
| The event I create for before update is working for forms that use the
| class but not for the gotfocus event. Is this to do with the fact that
| the event is called beforeupdate in both places and called ongotfocus
| and gotfocus?

Your class works for me.
But:
OnGotFocus occurs only if your form has not any control on it, that can
get focus
(textbox, combo, commandbutton...)
I think you would try OnActivate event instead.

--
KN