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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I find out which Form Is Open?

Status
Not open for further replies.

JimHutton

Programmer
Sep 26, 2003
25
0
0
GB
Hi I have several forms within my application.

On Form1 I have a textbox.

When the user enters some data then hits enter I would like the other open form to gain focus, and setfocus on the first control, text1.

E.g
[blue]
Private Sub Text1_LostFocus()
ActiveForm.Text1.SetFocus[green]'The Program needs to work out what the active form is...[/green]
End Sub[/blue]



Kindest Regards
Jim
-*b/]
 
I can do it like this if I know what the ActiveForm is...

[blue]
Sub SetFocusOnControl(TheActiveForm As Form)
On Error GoTo ErrHandle
TheActiveForm.SetFocus 'Set Focus on the active form
Exit Sub 'Exit Procedure to prevent the errhandle
ErrHandle:
Exit Sub 'Exit the Procedure as the form isn't loaded
End Sub

Private Sub Text1_LostFocus()
Call SetFocusOnControl(Form2)
End Sub[/blue]

But the problem is I don't know what the form is,
If I could send the form name to another store that could possibly work...

Any Ideas?

Thank you in advance

Jim
 
Screen.ActiveForm should give you the form that currently has the focus e.g.
Code:
Screen.ActiveForm.Text1.SetFocus
Hope that's what you are looking for

Regards

Daren


Must think of a witty signature
 
Brill thanx,

The problem being is that I have two forms which are open, Form1 being the owner form,

When the user enters the Reference Number in the textfield on FORM1, Form2 or Form3 will be shown with focus again.

Thanks
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top