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

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.