Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform OnLostFocus event Not Responding!! 1

Status
Not open for further replies.

srast

MIS
Nov 11, 2002
42
US
Hello all.
I have a main form and a subform. The subform has line items for a customer order. I have a unbound text box in the foooter to tally up one of the fields in the subform.
I want to use that number to run a test when the user leaves The SUBFORM, meaning, the subform loses focus, (or so I thought.) However, it doesn't seem to register the event. I tried testing this event in the VBA code window, using the Immediate window, simply doing as so:
(This is attached to the SUBFORM'S LostFocus event)

Private Sub Form_LostFocus()
Debug.Print "Testing..."
End Sub

Nothing happens!!
The same is true for the OnGotFocus event of the subform,and the OnActivate event as well.
Any ideas? I'm stuck!
Thanks.
Steve
 
try this instead

Dim frmCurrentForm As Form
Set frmCurrentForm = Screen.ActiveForm
debug.print "Current form is " & frmCurrentForm.Name


take a look at the "Screen Object" in the help file

hth Remember amateurs built the ark - professionals built the Titanic

[yoda]
 
The subform is a form in its own right, but when it's on your main form it is the Form property of a subform control, and it doesn't process all the events that it would as a freestanding form.

I suggest you try using the LostFocus event of the Subform control of the main form, e.g.

Code:
Private Sub MySubform_LostFocus()
 
duck72:
I recieved an answer that is similar to yours. The subform itself, as a free standing form, responds to events. However, it does not respond to to those events when it is a subform on a main form. However On the SUBFORM CONTROL itself, there are two events, OnEnter and OnExit, which you can use. I tried it out, and it works fine.
Thanks for your help.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top