From: Mat on 17 Dec 2009 18:00 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 17 Dec 2009 18:01 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 17 Dec 2009 18:12 Also I am using withevents in the class module: Private WithEvents frm As Access.Form
From: Mat on 19 Dec 2009 00:49 Actually the above works. The GotFocus event wasn't triggering when I thought it should.
From: Krzysztof Naworyta on 21 Dec 2009 11:34 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
|
Pages: 1 Prev: Combo box on an instance of a form Next: Ping Tony Toews - AutoFe question |