Which Form has the Focus?

dungstar

Registered User.
Local time
Today, 11:07
Joined
Mar 13, 2002
Messages
72
I have two main forms referring to one subform. I want that particular subform's combobox to detect which main form it is running under with a series of if statements to perform a function.

I tried the
Private Sub Form_GotFocus()
>>global variable = current form name
EndSub
but it doesn't seem to work as expected. How does this sub procedure work?

Is there a simple way of the subform knowing which main form its running under? What's the best way to check if form is has the focus?
 
On any of the subform's events (not a control on the subform) try

Sub Form_Open() 'for example

Select case me.parent.name

Case "MainForm1"
your code

Case "MainForm2"
your code

End select
End sub


HTH
 
Screen.ActiveForm.Name
 

Users who are viewing this thread

Back
Top Bottom