dbTalk Databases Forums  

frm.OnGotFocus = "[Event Procedure]"

comp.databases.ms-access comp.databases.ms-access


Discuss frm.OnGotFocus = "[Event Procedure]" in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mat
 
Posts: n/a

Default frm.OnGotFocus = "[Event Procedure]" - 12-17-2009 , 05:00 PM






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?

Reply With Quote
  #2  
Old   
Mat
 
Posts: n/a

Default Re: frm.OnGotFocus = "[Event Procedure]" - 12-17-2009 , 05:01 PM






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.

Reply With Quote
  #3  
Old   
Mat
 
Posts: n/a

Default Re: frm.OnGotFocus = "[Event Procedure]" - 12-17-2009 , 05:12 PM



Also I am using withevents in the class module:

Private WithEvents frm As Access.Form

Reply With Quote
  #4  
Old   
Mat
 
Posts: n/a

Default Re: frm.OnGotFocus = "[Event Procedure]" - 12-18-2009 , 11:49 PM



Actually the above works. The GotFocus event wasn't triggering when I
thought it should.

Reply With Quote
  #5  
Old   
Krzysztof Naworyta
 
Posts: n/a

Default Re: frm.OnGotFocus = "[Event Procedure]" - 12-21-2009 , 10:34 AM



Juzer Mat <matthew.kay (AT) optusnet (DOT) com.au> napisal
Quote:
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.