0

hi..i wanted to know how to set focus from form2 to say a desired textbox in form1..

Problem tht i face is if i give a setfocus() in form2 it gives me an "Invalid procedure call or argument error"....i have already set the focus in the form load event of form1...but when i come from form2 i want the focus given in form2 to work and not the form1 form load event focus...

how do i solve this problem?Kindly help

Edited by AncieV: n/a

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by AndreRet
0

OK try this

Form1.Text2.SetFocus

Here Text2 is the Textbox control you want to set focus. This code should be used from Form2
Hope this helps

Edited by kinwang2009: n/a

0

Kinwang, have a look at the error.

Ancie, your problem lies in the fact that your form1 is not showing. You can not set the focus to a control if it is not visible, in other words, by using

Load Form1

will not help, rather show the form and THEN set the focus -

Form1.Show
Text1.SetFocus

If there are many controls to load on your form, you might still get an error. If you do, rather use a timer to set the focus once the form is fully loaded.

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.